getify / You-Dont-Know-JS

A book series on JavaScript. @YDKJS on twitter.
Other
179.29k stars 33.48k forks source link

Types and Grammar, Chapter 4: Coercion #1711

Closed anurag001 closed 3 years ago

anurag001 commented 3 years ago

Edition: 1st

Book Title: Types and Grammar

Chapter: Chapter 4

Section Title: Coercion

Question:

var a = 42; 
var b = null; 
var c = "foo ; 
if (a && (b || c){ 
   console.log( "yep" ); 
}

Page-351 Code will work and it is also mentioned as the expression results in "foo" and gets coerced to true. In the entire chapter, if the code will work, we have shown the output of console in comments // output. Ideally, here it should be there. It will be easier to relate things. :)

getify commented 3 years ago

Per the contribution guidelines, I'm not accepting corrections on the first edition books (which have been published for more than 5 years now). Thank you.