Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. // It does't add a semicolon in the case of a leading parenthesis, so....
  2. // You will end up with a type error,
  3. // since Javascript parser assumes that "5" is a function and "(function(){ console.log(x) })"
  4. // is its parameter...
  5.  
  6. var x = 5 // JS parser does not add ; here
  7. (function(){ console.log(x) })()
  8.  
  9. // the code above will get an error: Uncaught TypeError: 5 is not a function(…)
  10. // because the interpeter read it like this
  11. var x = 5(function(){ console.log(x) })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement