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);
Sur cette page du site, vous pouvez voir la vidéo en ligne #04 || part1 || Operators in Javascript || Javascript learn with Us durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Mini Project 02 novembre 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 4 fois et il a aimé 0 téléspectateurs. Bon visionnage!