Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let foo = function() {
- console.log("Hello, World!");
- }// ; needed here
- // the IIFE won't run because the javascript above is not terminated with a semicolon
- // so it sees the IIFE below and thinks it's on the same line.
- (function() {
- console.log("Hello, world from this IIFE!");
- })();
- // the error is: (intermediate value)(...) is not a function
- // this is how the interpreter sees the code:
- // let foo = function() {
- // console.log("Hello, World!");
- // }(function() {
- // console.log("Hello, world from this IIFE!");
- // })();
- //this will run though:
- let foo = function() {
- console.log("Hello, World!");
- }
- foo();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement