#04 || part1 || Operators in Javascript || Javascript learn with Us

Publicado el: 02 noviembre 2024
en el canal de: Mini Project
4
0

Assalam o Alaikum!
In this video you will learn programming | php | javascript | | Css | Html | Flutter | Adobe Photoshop | Bootstrap | JQuery | and many more....


// Operator//

operators are symbols used to perform operations on valuesvariables, or expressions.

1. Arithmetic Operators................+,/,-,+,%,**

2. Assignment Operators..................=,+=,-=,*=,/=,%=

3. Comparison Operators................==,===,!=,!==,=,=

4. Logical Operators......................&&,||,!

5. Bitwise Operators..........................................&,|,^,~,

6. Conditional (Ternary) Operator...........condition ? ex1 : ex2

7. Type Operators.............typeof,instanceof

8.Nullish Coalescing Operator .....................??


1. Arithmetic Operators(+,/,-,+,%,**)

let a=3,b=2;

console.log(a+b);
console.log(a-b);
console.log(a/b);
console.log(a%b);
console.log(a**b); a^b

2. Assignment Operators(=,+=,-=,*=,/=,%=)

let a=3;
let b=3;
let c=2;
let d=2;
let e=2;
a+=2; // a=3+2 a=3
b-=3; // b=3-3 b=0
c*=2;//c=2*2 c=4
d/=2;//d=2/2 d=1
e%=2;//e=2%2 e=0
console.log(a);
console.log(b);
console.log(c);
console.log(d);
console.log(e);

3. Comparison Operators(==,===,!=,!==,=,)

let a=2; //int
let b="2"; //string
console.log(a==b);//it will check both are same or not,
//both are same so it will display true

console.log(a===b);//it will check both are same or not and also will check type(int,string etc) as you know one is int and second is string so it will display false


console.log(a!=b);

console.log(a!==b);




4. Logical Operators(&&,||,!)



let a = true, b = false;

console.log(a&&b); //AND operator ,both must be true for (true)
console.log(a||b);// OR operator, both must be false for (false)
console.log(!a); //not operator ,if a is false then ! will make true,if a is true ! will make false





5. Bitwise Operators(&,|,^,~ )


let a=2,b=3;
console.log(a&b);// AND operator
console.log(a|b); // OR operater
console.log(a^b);//XOR operater
console.log(~b);// Not operater




6. Conditional (Ternary) Operator(condition ? ex1 : ex2)



let age=25;

let result=(age greater than=18) ? "your age is valid for ID-CARD": "your age is not valid for ID-CARD";

console.log(result);





7. Type Operators(typeof,instanceof)



typeof: Returns the type of a variable.

instanceof: Checks if an object is an instance of a class or constructor.


console.log(typeof 3.4);//number

console.log([] instanceof Array); //true

console.log({} instanceof Object);//true






//8. Nullish Coalescing Operator (??)



Returns the right operand if the left is null or undefined.

let firstname=null ;//it is null
let lastname='hello'; //it is not null or undefined
let result= firstname??"marry";
let resulta= lastname??"marr22";
console.log(result);
console.log(resulta);


En esta página del sitio puede ver el video en línea #04 || part1 || Operators in Javascript || Javascript learn with Us de Duración hora minuto segunda en buena calidad , que subió el usuario Mini Project 02 noviembre 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 4 veces y le gustó 0 a los espectadores. Disfruta viendo!