An Immediately Invoked Function Expression (IIFE) is a JavaScript function that runs as soon as it is defined.
💻 Code: http://codepen.io/beaucarnes/pen/KWOrJO?editors=0010
🔗 Resource: https://en.wikipedia.org/wiki/Immediately-invoked_function_expression
🐦 Beau Carnes on Twitter: https://twitter.com/carnesbeau
⭐JavaScript Tutorials Playlists⭐
▶JavaScript Basics: https://www.youtube.com/playlist?list=PLWKjhJtqVAbk2qRZtWSzCIN38JC_NdhW5
▶Data Structures and Algorithms: https://www.youtube.com/playlist?list=PLWKjhJtqVAbkso-IbgiiP48n-O-JQA9PJ
▶Design Patterns: https://www.youtube.com/playlist?list=PLWKjhJtqVAbnZtkAI3BqcYxKnfWn_C704
▶ES6: https://www.youtube.com/playlist?list=PLWKjhJtqVAbljtmmeS0c-CEl2LdE-eR_F
▶Clean Code: https://www.youtube.com/playlist?list=PLWKjhJtqVAbkK24EaPurzMq0-kw5U9pJh
–
We’re busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.
Join our community at https://freecodecamp.com
Read great tech articles at https://medium.freecodecamp.com
Original source
8 responses to “Immediately Invoked Function Expression – Beau teaches JavaScript”
var a = 2;
function foo() {
var a = 3
console.log(a);
};
foo();
console.log(a);
foo();
prints:
3
2
3
This is different from the thing you said. It is because of es6?
well explained!
I think all the variables defined using 'var' are function scope in ES5 not global scope as you said @3:17
Is the video being slightly fast-forwarded while he types?
what is that js compiler you are using?
wow. normally when i watch JS videos on youtube, i don't understand what is happening at all. but i actually understand this video. this is amazing.
Dude your videos are awesome. Question for you – with ES6, do we need to use IIFE much anymore if at all?
Always wondered what this was for….. Could you make a video on 'use strict';? Thanks