-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_conversionOperation.js
72 lines (55 loc) · 1.52 KB
/
03_conversionOperation.js
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
72
let score = "33abc";
// console.log(typeof score);
let valueInNumber = Number(score);
// console.log(valueInNumber);
// console.log(typeof valueInNumber);
let type = true;
// console.log(typeof type);
let value = Number(type);
// console.log(value);
// console.log(typeof value);
/*
"33" => 33
"33abc" => NaN (Not a Number)
true => 1; false => false;
*/
let number = "33abc";
let convertInBoolean = Boolean(number);
// console.log(convertInBoolean);
// console.log(typeof convertInBoolean);
/*
1 => true; 0 => false;
"Soubhagya" => true;
"33abc" => true;
*/
let someNumber = 33;
let convertInString = String(someNumber);
// console.log(typeof convertInString);
// console.log(convertInString);
// **********************Operations*********************** //
let anotherValue = 3;
let negValue = -anotherValue;
// console.log(negValue);
let str1 = "Hello";
let str2 = " Soubhagya";
let str3 = str1 + str2;
// console.log(str3);
// console.log(2 + 2);
// console.log(2 - 2);
// console.log(2 * 2);
// console.log(2 / 2);
// console.log(2 % 2);
// console.log(2 ** 2);
// console.log("1" + 2);
// console.log(1 + "2");
// console.log(1 + "2" + 1);
// console.log("1" + 2 + 1);
// console.log(1 + 2 + "1");
let numberIncrement = 100;
numberIncrement++;
++numberIncrement;
// console.log(numberIncrement);
// console.log(+true); --> It print's 1.
// console.log(+""); -- It print's 0.
let num1, num2, num3;
num1 = num2 = num3 = 2.3; // Bad form of Code.