Object helpers are useful for inspection and copying, but most built-in copy patterns are still shallow.
- `Object.assign` and spread are shallow
- `freeze` and `seal` change mutability rules
- Entries are useful for iteration
JavaScript objects support descriptor-level control, computed accessors, explicit prototype creation, and different ways to check for properties.
- Descriptors control writability and enumerability
- Getters and setters run code on access
- `in` and `hasOwnProperty` answer different questions
These patterns solve different problems: recursion for self-referential logic, memoization for caching, currying for partial application, and debounce or throttle for rate control.
- Memoization trades memory for repeated-speed gains
- Debounce waits for quiet time
- Throttle limits call frequency
JavaScript regexes support pattern matching, modifiers, capture groups, and replacement operations for text processing.
- Flags change matching behavior
- Groups extract or organize matches
- Replacement supports templates and callbacks
JavaScript runs user code on a single main thread, but hosts like browsers and Node.js provide different APIs around that execution model.
- One call stack runs JS code
- Hosts provide timers, I/O, and APIs
- Browser and Node.js expose different globals and capabilities
Modern array work relies on iteration helpers, search helpers, and knowing which methods mutate the original array.
- `slice` copies, `splice` mutates
- `map` transforms and `forEach` does not return a new array
- `sort` mutates unless you copy first
Spread expands values, rest collects remaining values, and destructuring pulls parts of arrays or objects into variables.
- Spread copies one level deep
- Rest gathers leftovers
- Destructuring works with arrays and objects
Strict mode opts JavaScript into safer behavior by preventing some silent mistakes and tightening runtime rules.
- Disallows some sloppy-mode behavior
- Catches accidental globals more quickly
- Modules are strict by default
JavaScript testing usually starts with small unit tests, clear assertions, and selective mocking of outside dependencies.
- Unit tests focus on small behavior
- Assertions express expected results
- Mocking isolates external effects
`this` depends on how a function is called, and `call`, `apply`, and `bind` let you control that context explicitly.
- Arrow functions do not create their own `this`
- Method calls bind `this` to the receiver
- `bind` returns a new function
Use `let` and `const` for block scope, remember that `var` is function-scoped, and know that hoisting behaves differently across them.
- `var` is function-scoped
- `let` and `const` are block-scoped
- TDZ applies before `let` and `const` initialization
Accessibility in React still starts with semantic HTML, keyboard support, clear form behavior, and careful ARIA usage.
- React does not replace accessibility fundamentals
- Use semantic elements first
- Buttons, forms, and modals need keyboard-friendly behavior