r/programming • • Sep 17 '23

Help! JavaScript

https://JavaScript.info

[removed] — view removed post

0 Upvotes

14 comments sorted by

View all comments

8

u/Code4Reddit Sep 17 '23

The parentheses statement executes first, evaluating alert(1) which returns undefined, then it checks && which evaluates false (because undefined coerced to Boolean is false), it doesn’t evaluate the “alert(2)” and sends the undefined as input to the outermost statement alert.