Javascript Note Class 12 1
Javascript Note Class 12 1
- console.log("hello word");
- alert(" hello word");
- document.write("hello word");
Variable in JS :
Variables are containers for data
VARIABLE Rules:
Let : Variable can't be re-declared but can be updated. A block scope variable .
Data types in JS :
Number, String, Boolean, UnderFined, Null, Biglnt, Symbol :
Number:
String :
Boolean :
Ans: Boolean
Comment in JAVASCRIPT :
Part of code which is not executed.
/* this is a multi-line
Comment . */
Operators in JAVASCRIPT :
Used to perform some operation on data.
Arithmetic operators
+,-,*,/
- Modulus '% reminder'
- Exponentiation 'for power value ie. Ab , 23 eg. A**B'
- Increment '++ or a=a+1'
- Decrement '- - or a=a-1'
= += -= *= %= **=
=:
eg. a=5, b=6;
Let a=5;
+= :
eg. a += 5; // a= a + 5
Let a=5;
a += 5; // a= a + 5;
-= :
Eg. a -= 5; // a= a – 5
Let a=5;
A -= 2; // a= a – 2;
*= :
eg. a *= 5; // a= a * 5
let a=5;
a *= 5; // a= a * 5;
%= :
let a=5;
a %= 5 ; // a= a % 5;
let a=5;
a **= 5; // a= a**5;
/= :
Eg. a /= 5; // a= a / 5
Let a=5;
a /= 2;
Operators In JS :
Comparison Operators to compare 2 values .
Equal to == :
Eg. let a = 5, b = 2;
let a = 5; // number
Eg. let a = 5 , b = 2;
Let a = 5, b = 5 ;
let a = 5; // number
let a = 5; // number
Logical Operators :
Logical AND &&
Logical OR ||
Logical NOT !
let a = 6;
let b = 5;
let a = 6 ;
let b = 5;
Console.log (" cond1 && cond2 = ", cond1 && cond2); // false
Logical OR || :
Eg.
//Logicat Operators
let a = 6;
let b = 5 ;
let a = 6;
let b = 5 ;
Console.log (" !(6<5) = ", !(a < b)); // false but answer is TRUE