Open vikramlc opened 4 years ago
Floating Point Precision:
0.2 + 0.4
0.6000000000000001
(0.2 + 0.4) === 0.6
false
(1).toString(2);
"1"
(5).toString(2);
"101"
(1/5).toString(2);
"0.001100110011001100110011001100110011001100110011001101"
(0.2).toString(2);
"0.001100110011001100110011001100110011001100110011001101"
(0.2).toFixed(20);
"0.20000000000000001110"
(0.2).toFixed(2);
"0.20"
(20.2).toFixed(20);
"20.19999999999999928946"
20.2 * 100
2020
2020.0
2020
Big Int:
Number.MAX_SAFE_INTEGER
9007199254740991
9007199254740991 + 10
9007199254741000
9007199254740991 + 100
9007199254741092
9007199254740991n + 100n
9007199254741091n
parseInt(9007199254740991n) + 1000
9007199254741992
10n * 3n
30n
10n/2n
5n
10n - BigInt(3)
7n
Math operations:
function randomIntBetween(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
console.log(randomIntBetween(1, 20); // 17
Strings:
`${1}`
"1"
'hello'.big
ƒ big() { [native code] }
'hello'.big()
"<big>hello</big>"
'hello'.toLocaleUpperCase
ƒ toLocaleUpperCase() { [native code] }
'hello'.toLocaleUpperCase()
"HELLO"
'hello'.toLowerCase()
"hello"
'hello'.toUpperCase()
"HELLO"
'hello'.startsWith('he');
true