Skip to content

Commit 6315b93

Browse files
committed
Updated 03 Conversion Operations JS
Added Notes of Operations (what to use, what to not) & Added a MDN link of Increament Operators
1 parent f013e47 commit 6315b93

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

01_Basics/03_conversionOperations.js

+45-8
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
/* 1. When converting in Number,
55
(i) */
66
let score = "33" // "33" is a string.
7-
console.log(typeof score);
8-
console.log(typeof(score));
7+
// console.log(typeof score);
8+
// console.log(typeof(score));
99
// We can write console.log in both the ways.
1010

1111
// Converting "33" string into number,
1212
let valueInNumber = Number(score) // We can write String, Boolena e.t.c Data types in the place of Number.
13-
console.log(typeof valueInNumber); // Output : number
14-
console.log(valueInNumber); // Output : 33
13+
// console.log(typeof valueInNumber); // Output : number
14+
// console.log(valueInNumber); // Output : 33
1515

1616
// (ii)
1717
/* let score = "33abc"
@@ -39,8 +39,8 @@ console.log(valueInNumber); // Output : 33
3939
(i) */
4040
let isLoggedIn = 1
4141
let booleanIsLoggedIn = Boolean(isLoggedIn)
42-
console.log(typeof booleanIsLoggedIn); // Output : boolean
43-
console.log(booleanIsLoggedIn); // Output : true
42+
// console.log(typeof booleanIsLoggedIn); // Output : boolean
43+
// console.log(booleanIsLoggedIn); // Output : true
4444

4545
/* (ii)
4646
Same in the case of 0 console.log(booleanIsLoggedIn); will return false */
@@ -61,6 +61,43 @@ console.log(booleanIsLoggedIn); // Output : True */
6161
(i) */
6262
let someNumber = 33
6363
let stringNumber = String(someNumber)
64-
console.log(typeof stringNumber); // Output : String
65-
console.log(stringNumber); // Output : 33
64+
// console.log(typeof stringNumber); // Output : String
65+
// console.log(stringNumber); // Output : 33
6666

67+
// *************************************Operations********************************************
68+
69+
70+
// Operation 1,
71+
let value = 3
72+
let negValue = -value
73+
// console.log(negValue); // Output : -3
74+
75+
// Other Operations
76+
// console.log(2+2);
77+
// console.log(2-2);
78+
// console.log(2*2);
79+
// console.log(2**3); // 2 to the power 2*2*2
80+
// console.log(2/2);
81+
// console.log(2%2); // For remainder
82+
83+
// Operation 2,
84+
let str1 = "Hello!"
85+
let str2 = " Ayush"
86+
let str3 = str1 + str2
87+
// console.log(str3); // Output : Hello! Ayush
88+
89+
// Operations which are not a good practice,
90+
// console.log("1" + 2); // Output : 12
91+
// console.log(1 + "2"); // Output : 12
92+
// console.log("1" + 2 + 2); // Output : 122
93+
// console.log(1 + 2 + "2"); // Output : 32
94+
// console.log(+true); // Output : 1
95+
// console.log(+""); // Output : 0
96+
let num1, num2, num3
97+
num1 = num2 = num3 = 2 + 2
98+
// console.log(num1, num2, num3); // Output : 4 4 4
99+
100+
//*************************************Increament Operators***********************************
101+
102+
// Postfix & Prefix Increament,
103+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Increment

0 commit comments

Comments
 (0)