In most circumstances, this is not an issue, but you do need to be aware that very large numbers may be non-consecutive. It’s also possible to accidentally end up with a tiny rounding error when dividing numbers that should give a whole number. It is wise to use strings for ids, and to calculate financial transactions in pennies, cents, or some other non-divisibale denomination.
Convert a string to a number using parseInt or parseFloat:
Convert a number to a string simply by concatenating it with a string, like so:
"" + 123;
or by using backticks, like this:
const x = new Number(12); x.toFixed(3); // returns "12.000"
1 / 0 === Infinity; // returns true -1 / 0 === -Infinity; // also true
NaN - Not a Number
1 / "a"; // NaN
I get NaN. Note that NaN does not equal NaN. This is part of the specification and actually makes sense if you think about it. Not a Number doesn’t equal anything.