Advanced Concepts Problems Flashcards
All:
https://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/
https://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/
Hoisting and the var Statement:
https://launchschool.com/lessons/43f23069/assignments/39f50f91
https://launchschool.com/lessons/43f23069/assignments/39f50f91
Strict Mode
Problem at bottom of page
https://launchschool.com/gists/406ba491
https://launchschool.com/gists/406ba491
Closures:
https://launchschool.com/lessons/43f23069/assignments/9362d2cf
https://launchschool.com/lessons/43f23069/assignments/9362d2cf
Private data,
at bottom of page:
https://launchschool.com/lessons/43f23069/assignments/3df10c91
https://launchschool.com/lessons/43f23069/assignments/3df10c91
IIFE
https://launchschool.com/lessons/43f23069/assignments/69bab49c
https://launchschool.com/lessons/43f23069/assignments/69bab49c
Shorthand:
https://launchschool.com/lessons/43f23069/assignments/c6c682cd
https://launchschool.com/lessons/43f23069/assignments/c6c682cd
do this but with no conditional statements
https://launchschool.com/exercises/81b953d7?track=javascript
do this (doesn’t work so good with hidden data)
https://launchschool.com/exercises/d30df1f2?track=javascript
https://launchschool.com/exercises/d30df1f2?track=javascript
Advanced concepts quiz:
https://launchschool.com/quizzes/a669620d
https://launchschool.com/quizzes/a669620d
What does this do?
var foo = 10;
function bar() {
if (foo > 20) {
var foo = 50;
}
console.log(foo);
foo += 10;
}
bar();
bar();
bar();
The declaration for foo on line 5 of the original code gets hoisted to a function-scoped variable, foo, that shadows the foo variable on line 2. Since we’re not initializing the variable inside bar, its value is undefined, and that’s what gets logged each time we execute line 8 in the original code.
function bar() {
var foo;
if (foo > 20) {
foo = 50;
}
console.log(foo);
foo += 10;
}
var foo;
foo = 10;
bar();
bar();
bar();
The following code has console.log calls on lines 1, 4, 8, 10, and 16. In what sequence will those 5 log calls execute? (or not at all?)
console.log(foo());
function foo() {
console.log(‘Waiting for bar!’);
}
function foo() {
console.log(foo);
function bar() {
console.log(‘bar again’);
}
bar();
function bar() {
console.log(‘bar again and again’);
}
}
8 16 1