Hi, while the conversion hacks are interesting, PLEASE note in bold (as with Math.*) that proper readable methods should be used. It's really cryptic in the real life code to decode these tricks because people think this is the only and proper way instead of these:
constisFalse=Boolean(0);constnumeric=String(29);constinteger=Number("36");// or better parseInt("36", 10)
Beware - truncating an integer and using any of Math.floor, Math.ceil, and Math.round are NOT the same thing:
console.log(-23.9|0);// Result: -23console.log(Math.floor(-23.9));// Result -24console.log(Math.ceil(-23.9));// Result -23console.log(Math.round(-23.9));// Result -24console.log(23.9|0);// Result: 23console.log(Math.floor(23.9));// Result 23console.log(Math.ceil(23.9));// Result 24console.log(Math.round(23.9));// Result 24
Hi, while the conversion hacks are interesting, PLEASE note in bold (as with
Math.*) that proper readable methods should be used. It's really cryptic in the real life code to decode these tricks because people think this is the only and proper way instead of these:nice corrections, thank you.
Beware - truncating an integer and using any of
Math.floor,Math.ceil, andMath.roundare NOT the same thing:In the "Every and Some" paragraph
more_random_numbers.some(isPositive)returnstrue😉Thx for the correction bro
Hi,
In the first example, the result includes an extra element:
4wow, i am using js for years, but the
float to intis new, thanks mani hope this posting helpfull for u bro, thx!
yea, it also good one.
There's a typo in Convert to Boolean code section. It should be:
console.log(typeof isTrue) instead of:
console.log(typeof true)
Thx for correction bro