This Chair — JavaScript Guess which chair this sits in from how the function is called: 7 levels of this binding, call, apply and bind, arrow functions and new.
What you learn in this game this inside a regular function is not decided when the function is written but when it is called. The way it is called picks one of five chairs: the object left of the dot (x.f()), a plain call (f()), call/apply/bind, new, or an arrow function that borrows this from where it was written.
Lessons this game drills The this Keyword : The value of this is decided by how a function is called: obj.method() means this is obj, the object left of the dot. A method that is copied into a variable…Arrow Functions : An arrow function is a shorter way to write a function: const name = (parameters) => { return result; };. When the function's body is a single expression…Classes : A class is a mould for making objects. An object made with new is called an instance. The constructor runs automatically when new is called and stores data on…Callbacks : A callback is a function passed to another function as an argument, and the function that receives it is the one that calls it. Examples of such functions are…Object Expert : Master JavaScript objects: 14 levels of properties, nesting, destructuring and spread. The most visual JS object game for understanding data structures.Console Oracle : Foretell what the console prints in Mbah Rimba's tent: 12 levels of types, coercion and run order that sharpen your mental model of JavaScript.Hero Controller : Wire listeners to Bang Jaya's panel so click, keydown and timers take the hero to the mine: 12 levels of DOM events, setInterval and closures.Array Tile Map : Build Kak Piksel's cabinet game maps from 2D arrays: 13 levels of nested loops, Array.from, map, copies and recursion.Condition Crafter : Build if/else logic: 15 levels of booleans, operators, ternaries and truthy/falsy. A JavaScript conditionals game for beginners new to logic.