Numbers in JavaScript
What I have learnt from basic JavaScript Numbers
In JavaScript Every Number is Floating Point Number(Like Decimal Number). Actually in double-precision 64 bit binary format 😳️ Ahh Too much . But yes Like double in c or c++
so 23 === 23.0 it returns True which is not the case in other programming Languages
so the following are the same
Number.parseFloat('23.59px') // returns 23.59
23 === 23.0 //True
43===43.000
Here Note I have used"===" instead of "==". Ah that's another JavaScript thing. We will discuss it in another post
Some functions we care about
Converting a String into Number using
NumberfunctionNumber('23') // returns 23 Number('yes') // returns 'NAN'(Not a Number)Here is another very useful function
Number.parseInt(argument,radix)It returns an Integer(don't confuse here It is actually a floating Point Number under the hood) of the specified radix or baseNumber.parseInt('23px') -> returns 23Now look How useful it is and you know how to use it with css units 😊️
Similarly Number.parseFloat(argument) -> returns a Floating point Number
Number.parseFloat('23.59px') // returns 23.59If the Number can not be parsed from the argument it returns
"NAN"
4.
The Number.isFinite() method determines if the the passed value is a finite Number that is the number is neither Infinity nor NAN
console.log(Number.isFinite(1/0));
//expected false
console.log(Number.isFinite(5/10));
//ecxpected true
So this is what I have learnt by going through a tutorial of JavaScript Number

