Videos / Web Dev
Episode 1 of 9 · The interview course
JavaScript interview: scope, hoisting and this Included with a plan
This video is included with a plan. The first three lessons of every track are free, with their boards and videos. A plan unlocks every lesson, board, video, lab and paper for one price.
View plans → Already a member? Sign in
Chapters
The question that opens it 0:00 Two phases before a line runs 0:16 The creation phase 0:35 The execution phase 0:54 Hoisting, defined well 1:12 Var gives you undefined 1:31 Let and const throw 1:48 The temporal dead zone 2:07 Typeof, and the one place it throws 2:24 The question everyone gets asked 2:43 The output 2:58 Why, line by line 3:15 Scope: var against let and const 3:32 Redeclare, reassign, and which to reach for 3:50 Const does not freeze 4:08 Function declarations hoist whole 4:26 Function expressions and arrows do not 4:42 Classes are in the dead zone too 5:00 Function scope, in three kinds 5:18 Block scope 5:35 The scope chain 5:52 Shadowing, and which way it goes 6:09 What a closure actually is 6:27 The counter, and where it lives 6:46 Closures for data privacy 7:02 The IIFE and the module pattern 7:19 A function factory 7:40 Once, and memoise 7:56 When not to reach for a closure 8:16 The loop that logs three three three 8:35 Why it is three three three 8:50 Fix one: one binding per turn 9:06 Fix two: the IIFE 9:25 Currying: what and why 9:42 Add one two three 9:58 A generic curry, and function length 10:17 Partial application is not currying 10:35 This is decided by the call site 10:54 Rule one: new 11:12 Rule two: call, apply, bind 11:28 Rule three: the object before the dot 11:46 Rule four: default 12:01 This, lost as a callback 12:19 This in setTimeout and on an event listener 12:36 The two fixes, and the old React one 12:55 Arrows have no this of their own 13:13 The arrow that breaks 13:29 Call against apply against bind 13:46 MyBind by hand 14:06 The payoff 14:26 JavaScript interview: scope, hoisting and this. Here is the first thing an interviewer will hand you. A function that logs two variables before either is declared. One log prints undefined. The other throws. Same function, two l
Mark as watched Saved in this browser only.