maxtester
9 years agoContributor
Datatype number with value one is the same as boolean true??
Hi all, I Have a question regarding the datatypes. In my script I have a function that returns boolean true or a number. Like this: //Returns a true or a number var Return = function1() ...
- 9 years ago
In JavaScript (and JScript) 1 is a truthy value, meaning it has a boolean value of true. That is, Boolean(1) == true. All numbers other than 0 are truthy, 0 is falsey.
http://james.padolsey.com/javascript/truthy-falsey/
http://www.sitepoint.com/javascript-truthy-falsy/
http://stackoverflow.com/questions/19839952/all-falsey-values-in-javascript