let billion = 1000000000;
let billion = 1e9; // The same
let ms = 0.000001;
let ms = 1e-6;
let num = 255;
num.toString(); // "255"
// 숫자에 바로 toString()을 호출
alert( 255..toString() ); // "255"
✔️ Base
// (+) and Number is strict
alert( +"100px" ); // NaN
alert(Number("100px")); // NaN
// parseInt and parseFloat
alert( parseInt('100px') ); // 100
alert( parseInt('12.3') ); // 12
alert( parseFloat('12.3.4') ); // 12.3
// 1.2345 -> 1.23
let num = 1.2345;
// (*) Multiply-and-divide
Math.floor(num * 100) / 100;
// (**) toFixed(n)
// Rounds up or down to the nearest value like Math.round()
// Its result of toFixed is a string, if you want number, use "Number()" call or "+num.toFixed(n)".
num.toFixed(2);
num.toFixed(5); // 1.23450
alert( Math.random() );
alert( Math.max(3, 5, -10, 0, 1) ); // 5
alert( Math.min(1, 2) ); // 1
alert( Math.pow(2, 10) ); // 2 in power 10 = 1024
// isNaN: return true if its argument is not a number
alert( isNaN(25) ); // false
alert( isNaN("str") ); // true
// isFinite: converts its argument to a number and returns true if it’s a regular number
alert( isFinite("25") ); // true
alert( isFinite("str") ); // false
alert( 0.1 + 0.2 == 0.3 ); // false
alert( 0.1 + 0.2 ); // 0.30000000000000004
✔️ How to solve
// (*) toFixed(n)
let sum = 0.1 + 0.2;
alert( sum.toFixed(2) ); // 0.30
alert( +sum.toFixed(2) ); // 0.3, Unary plus