Part 2— Unique JavaScript Notes by Sivaganesh Panditi
Javascript has some different operators and datatypes when compared with other programming languages
Let’s dive into them
Operators
+ for addition
- for substraction
* for multiplication
/ for division
++ for increment
— for decrement
== for comparing value
=== for comparing value with type
&& for and
|| for or
> for greater than
< for lessthan
typeof says type of variable
instanceof gives true/false by comparing instance for Object/Array/Date
and some more bitwise operators
Above operators we all know. But Java script have one more. It is
** is an exponential operator which equals to Math.pow(x,2);
eg: 5**2 values 25
&&= says if first value is true then second value will be assigned
let x=1;
x&&=2 values 2
let x=0; // which represents false
x&&=2 values 0
||= says if first value is false then second value will be assigned
let x=1;
x||=2 values 1
let x=0; // which represents false
x&&=2 values 2
??= says if first value is Null or undefined then second value will be assigned
let x;
x||=2 values 2
Datatypes
String, Number (all are 64-bit floating points), Bigint (to hold higher values), Boolean, Undefined, Null, Object, Symbol
Object again classified as Object, Array, and date
Examples:
const person={name: ‘siva’, mobile: ‘1234567890’ }; //Object declaration
const cars=[“Tata”, “Toyota”]; //Array declaration
const dt=new Date(“2024–04–07”); // Date declaration
const bigNum= new BigInt(“12345678946679964461251133321555”); // Bigint declaration