Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. let foo = function() {
  2. console.log("Hello, World!");
  3. }// ; needed here
  4.  
  5. // the IIFE won't run because the javascript above is not terminated with a semicolon
  6. // so it sees the IIFE below and thinks it's on the same line.
  7.  
  8. (function() {
  9. console.log("Hello, world from this IIFE!");
  10. })();
  11.  
  12. // the error is: (intermediate value)(...) is not a function
  13.  
  14. // this is how the interpreter sees the code:
  15. // let foo = function() {
  16. // console.log("Hello, World!");
  17. // }(function() {
  18. // console.log("Hello, world from this IIFE!");
  19. // })();
  20.  
  21.  
  22. //this will run though:
  23. let foo = function() {
  24. console.log("Hello, World!");
  25. }
  26. foo();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement