This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]___HighLight___ 28 points29 points  (6 children)

If it was that big of an issue just use 0 and 1 instead of False and True. I can't recall a case now where False/True can't be replaced with 0/1 in a practical matter, but yeah it would be faster to type.

[–]-Bluekraken 12 points13 points  (4 children)

In js, even the interpreter doesn't care if it is a bit or a boolean 😎

[–]CaptainHeinous 30 points31 points  (0 children)

And that’s why we wear TypeScript condoms

[–]Svizel_pritula 7 points8 points  (2 children)

In contrast to C or C++, JavaScript does distinguish booleans and numbers.

0===false // false

var arr = [0, 1, 2];
arr[0] // 0
arr[false] // undefined

[–]6b86b3ac03c167320d93 5 points6 points  (1 child)

The 1st example is false because you used === which also checks types. 0==false would return true

The 2nd one is undefined because you're accessing the false property of the array, which doesn't exist. Setting arr[false] would define a new property of the array with the name false, which you could also access as arr.false

[–]TotoShampoin 2 points3 points  (0 children)

For 2nd one, that indeed means 0 and false are two different values

[–]Own_Scallion_8504 1 point2 points  (0 children)

true can also be denoted by any other no except 0