-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperation.js
More file actions
71 lines (45 loc) · 1.46 KB
/
Copy pathOperation.js
File metadata and controls
71 lines (45 loc) · 1.46 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
console.log(2**3); // Exponentiation
console.log(10 % 3); // Modulus
console.log(Math.sqrt(16)); // Square root
console.log(Math.abs(-7)); // Absolute value
console.log(Math.round(4.4)); // Rounding
console.log(Math.round(4.6)); // Rounding
console.log(Math.ceil(4.2)); // Ceiling
console.log(Math.floor(4.8)); // Floor
console.log(Math.min(3, 1, 4, 2)); // Minimum
console.log(Math.max(3, 1, 4, 2)); // Maximum
console.log(Math.random()); // Random number between 0 and 1
console.log(Math.floor(Math.random() * 100) + 1); // Random number between 1 and 100
let st1r = "Hello";
let st2r = "World";
console.log(st1r + " " + st2r); // String concatenation
let num1 = 10;
let num2 = 20;
console.log(num1 + num2); // Numeric addition
console.log("1" + 2); // String and number concatenation
console.log("1" + 2 + 3); // Left to right evaluation
console.log(1 + 2 + "3"); // Left to right evaluation
console.log(+true); // Unary plus
console.log(+false); // Unary plus
console.log(+"123"); // Unary plus
console.log(+""); // Unary
console.log(+null); // Unary plus
console.log(+undefined); // Unary plus
let x = 5;
++x; // Increment
console.log(x);
let y = 5;
y++; // Increment
console.log(y);
let a = 5;
--a; // Decrement
console.log(a);
let b = 5;
b--; // Decrement
console.log(b);
Postfix increment
let x = 3;
const y = x++; // x is 4; y is 3
Prefix increment
let x = 3;
const y = ++x; // x is 4; y is 4