loading...

re: The shortest way to conditional insert properties into an object literal VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Just make sure to internalize what JavaScript considers truthy and you won't think this is a "gotcha" anymore. So in your specific case you'd prob...
 

AFAIK, this is considered as a bad practice to use typeof to check the number, as NaN is also has type number (e.g. typeof NaN === "number"; // -> true). Moreover, typeof when used against number will return number, as a result, in lower case (i.e. not Number but number).

Yeah the casing of number was just a typo. Adjusted it to check for NaN.

Code of Conduct Report abuse