TillerMan12 [none/use name] to technology • 3 years agoAllied Forces when no anglosimagemessage-square41 fedilinkarrow-up156file-text
arrow-up156imageAllied Forces when no anglosTillerMan12 [none/use name] to technology • 3 years agomessage-square41 Commentsfedilinkfile-text
minus-squareinvalidusernamelol [he/him]hexbear14·edit-23 years agoMy favorite thing about JS is that it has true and false evaluations that are more guidelines than rules Pop quiz: Which is true and which is false? a) "false" == true b) "0" == true c) [] == true d) " " == true (They're all true) link
minus-squareinvalidusernamelol [he/him]hexbear10·edit-23 years agoI still think JS is an incredibly useful language, but god damn is the concept of "truthy" and "falsey" just insane. link
minus-squareMoreLikeSexbearLmao [he/him]hexbear7·3 years agoI disagree, I think python handles it pretty well. JS just has some pretty bad rules for truthiness. In python: numbers are truthy if they're non-zero containers and strings are truthy if they are non-empty a regex result is truthy if it matched something the None object is not truthy custom objects are truthy by default, but you can define the thruthiness function link
minus-squareinvalidusernamelol [he/him]hexbear11·3 years agoThe takeaway is that you should always use === in JS lol link
minus-squareinvalidusernamelol [he/him]hexbear10·3 years agoJust passing empty lists and the integer 0 into random fields. link
My favorite thing about JS is that it has true and false evaluations that are more guidelines than rules
Pop quiz:
Which is true and which is false?
a)
"false" == true
b)
"0" == true
c)
[] == true
d)
" " == true
(They're all true)
That is horrifying.
I still think JS is an incredibly useful language, but god damn is the concept of "truthy" and "falsey" just insane.
I disagree, I think python handles it pretty well. JS just has some pretty bad rules for truthiness.
In python:
numbers are truthy if they're non-zero
containers and strings are truthy if they are non-empty
a regex result is truthy if it matched something
the None object is not truthy
custom objects are truthy by default, but you can define the thruthiness function
deleted by creator
The takeaway is that you should always use
===
in JS loldeleted by creator
Just passing empty lists and the integer 0 into random fields.