r/javascript • • May 28 '19

What are some JavaScript things beginners don't know?

333 Upvotes

383 comments sorted by

View all comments

28

u/DerGernTod May 28 '19

coercion in general

false == 'false' // false
false == '' // true
false === '' // false
var x = false || 'foo' // x is 'foo'
var y = true || 'foo' // y is true
var z = y && x // z is 'foo'

-1

u/TheIncorrigible1 May 28 '19

Please use real code blocks when you're going to post a long snippet otherwise it gets cut off in vertical displays (indent your code block with four spaces)