-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlecture2.js
More file actions
51 lines (43 loc) · 1.12 KB
/
Copy pathlecture2.js
File metadata and controls
51 lines (43 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Comments
console.log("Comments in JS - Parts of code which not runs");
// single line comment
/*
Multiple line comments
*/
// Operators
// Arithmetic Operator
let a = 7;
let b = 5;
let c = a + b;
console.log("a = ",a,"& b = ",b);
console.log("a + b = ",c);
console.log("a - b = ",a - b);
console.log("a * b = ",a * b);
console.log("a / b = ",a / b);
console.log("a % b = ",a % b); // Modulus operator -> Remainder
console.log("a ** b = ",a ** b); // Exponentiation operator
// Unary Operator
a++; // a = a + 1;
console.log("a = ",a);
a--; // a = a - 1;
console.log("a = ",a);
console.log("++a = ",++a);
// Assignment Operators
let d = 5; // =
console.log("d = ",d);
d += 5; // d = d + 5
console.log("d = ",d);
// same we use : -=,*=,/=,**=
// Comparison Operators
b = "8";
console.log("a == b ->",a==b);
console.log("a != b ->",a!=b);
console.log("a === b ->",a===b);
console.log("a !== b ->",a!==b);
//In same way we use >,<,>=,<=
// Logical Operator
let cond1 = a == b; //true
let cond2 = a > b; //false
console.log("cond1 && cond2 -> ",cond1 && cond2);
console.log("cond1 || cond2 -> ",cond1 || cond2);
console.log("!(a>b) -> ",!(a>b));