Lesson 7 of 55
javascriptScope, Closures & the Execution Context
13 mins
Course progress13%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 7 of 55
javascript13 mins
Keep these ideas in mind as you work through the lesson.
Two main scopes:
let/const.function makeCounter(){
let count = 0;
return function(){
count += 1;
return count;
};
}
const counter = makeCounter();
console.log(counter()); // 1
console.log(counter()); // 2