Step 3 / Select topic JavaScript Medium

What this bank covers

  • Bare calls have undefined this in strict mode
  • A method call binds this to the receiver
  • Extracting a method drops the receiver
  • call sets this for that call
  • apply sets this and takes an argument array
  • bind returns a new function with this locked
  • call cannot override a bound this
  • An arrow ignores this passed to call
  • An arrow inside a method sees that method this
  • An arrow property does not receive the object
  • new binds this to the new instance
  • A closure sees later assignments
  • var in a for loop is one binding
  • let in a for loop creates a binding per iteration
  • A returned function keeps the outer parameter
  • A missing own property is found on the prototype
  • An own property shadows an inherited one
  • A class method lives on the prototype
  • A class field is an own property of each instance
  • A static method lives on the constructor
  • A derived constructor must call super before using this
  • super.method calls the parent method
  • instanceof walks the prototype chain
  • Object.create(null) has no Object.prototype methods
  • Object.getPrototypeOf returns the prototype
  • Promise reactions are microtasks
  • setTimeout callbacks are macrotasks
  • Sync code, then microtasks, then timers
  • An async function always returns a promise
  • An async function runs synchronously until its first await
  • await on a non-promise still resumes as a microtask
  • throw inside an async function rejects its promise
  • Promise.all rejects on the first rejection
  • Promise.allSettled waits and does not reject for an input
  • Promise.race settles with the first settlement
  • Promise.any fulfills with the first fulfillment
  • queueMicrotask runs before setTimeout of 0
  • then returns a new promise
  • A non-promise return becomes the next fulfillment
  • Returning a promise from then adopts it
  • finally keeps the fulfillment value
  • next runs a generator to the next yield
  • next(value) supplies the yield expression
  • for...of uses Symbol.iterator
  • A plain object is not iterable
  • The iterator protocol is { value, done }
  • Map iterates in insertion order
  • Map can use an object as a key by identity
  • Map does not match a different object with the same contents
  • Set treats NaN as the same value
  • A primitive WeakMap key throws
  • WeakMap is not iterable
  • Symbol() creates a unique symbol
  • Symbol.for returns a shared registry symbol
  • Object.keys omits symbol keys
  • Object.getOwnPropertySymbols returns symbol keys
  • Symbol.toPrimitive handles coercion hints
  • The default sort comparator compares strings
  • sort mutates the array in place
  • A numeric comparator is (a, b) => a - b
  • forEach skips holes in a sparse array
  • map keeps holes and skips their callbacks
  • A hole is a missing index
  • Spreading a hole yields undefined
  • reduce without an initial value starts at the first element
  • reduce on an empty array with no initial value throws
  • flat flattens one level by default
  • flatMap maps, then flattens one level
  • toSorted returns a copy
  • at(-1) returns the last element
  • Tagged templates pass parts, then values
  • Rest parameters collect a real array
  • arguments is array-like
  • function.length stops at the first default or rest
  • new.target is undefined without new
  • Private fields are not readable from outside the class
  • Private in is the brand check
  • A property read runs the getter
  • A property write runs the setter
  • Object.keys skips non-enumerable properties
  • Object.freeze does not freeze nested objects
  • Object.seal locks the property set
  • structuredClone preserves Date objects
  • JSON turns a Date into a string
  • structuredClone rejects functions
  • A global regexp keeps lastIndex
  • match on a global regexp collects every match
  • replace can take a replacer function
  • Imported let bindings are live
  • Imports are linked before the module body runs
  • A finally return replaces the try return
  • A switch body is one lexical scope
  • Strict delete of a bare identifier is a SyntaxError
  • Static blocks run during class evaluation
  • Default expressions run when the function is called
  • Destructured parameters can default
  • Object rest keeps enumerable own string keys
  • Nested microtasks drain before the next timer
  • A then callback jumps ahead of an already queued timer
  • Code before the first await runs on the caller stack
  • map(parseInt) passes the index as the radix
  • forEach does not wait for async callbacks
  • Deduplicating with a Set
  • Index by key before repeated lookups