Wednesday, September 29, 2021

JavaScript- Relational Operators- Boolean

Following code fragement will be help you understand the relational operators resulting in boolean values.

var a = 10;
console.log(a == 0); // false
console.log(a == 10); // true

console.log(a != 10); // false
console.log(a != 5); // true

console.log(a > 5); // true
console.log(a > 10); // false
console.log(a > 15); // false
console.log(a >= 10); // true

console.log(a < 5); // false
console.log(a < 10); // false
console.log(a < 15); // true
console.log(a <= 10); // true

Tuesday, September 28, 2021

JavaScript- Boolean

Boolean variables/expressions refers to one of two values

  • true
  • false

Boolean expressions are usually generated using relational operators

Sunday, September 26, 2021

JavaScript- Basic Arithmetic Operators

Following table shows practical examples to understand how basic arithmetic operator works.

Before Statement After Remarks
x y x
Assignment
10 3 x = y 3
Add/Substract/Multiply/Divide
10 3 x = x + y 13 Addition
10 3 x = x - y 7 Subtraction
10 3 x = x * y 30 Multiplication
10 3 x = x / y 3.3333333333333335 Division
10 3 x = x ** y 1000 Power (103)
10 3 x = x % y 1 Reminder of the Division
Shorthand Add/Substract/Multiply/Divide
10 3 x += y 13 Shorthand Addition
10 3 x -= y 7 Shorthand Subtraction
10 3 x *= y 30 Shorthand Multiplication
10 3 x /= y 3.3333333333333335 Shorthand Division
10 3 x **= y 1000 Shorthand Power (103)
10 3 x %= y 1 Reminder of the Division

JavaScript- Understanding Numbers

Below table will help you to understand the values representable with number data type

Statement i typeof(i) Remarks
i = 0 0 number Fixed point number
i = 1.0 1 number Floating point number with Zero
i = 1.2 1.2 number Floating point number
i = 1.2e3 1200 number Scientific Notation
i = 1.2e200 1.2e+200 number Scientific Notation
i = 1 / 0 Infinity number Divide by Zero
i = NaN NaN number Not a Number
i = 1234567890123456 1234567890123456 number Precise with 15 digit
i = 12345678901234567 12345678901234568 number Precision is lost
i = 1.2e20000 Infinity number Value cannot be represented with number
i = Number.MIN_VALUE 5e-324 number Minimum Value for supported by number data type
i = Number.MAX_VALUE 1.7976931348623157e+308 number Maximum Value for supported by number data type

Saturday, September 25, 2021

JavaScript- Data Types

  • Number
    • All Negative, Positive, Integral and Floating point numbers.
  • String
    • Characters and Numbers
  • Boolean
    • True or False
  • Object
    • Objects, DateTime, Arrays and null etc
  • Undefined
    • When nothing assigned to a variable
    • Or can be assigned to a variable when the existing data is not needed
  • Function
    • A code block consisting multiple statement to perform a specific purpose 


JavaScript- Getting Started

 To start learning JavaScript, you have to choose a tool through which you can test your "Code" 

There are variety of options available.

Most common one is

  • Writing a html page, embed JavaScript and Open it in a browser (ie. Chrome, Edge, Firefox etc).

Few other options are.

  •  Install NodeJs and use NodeJS Command line
  • Open the browser, open developer tools and use Console to test your JavaScript statements.