DEV Community

Calie Rushton
Calie Rushton

Posted on

What I learned last week (38/24)

  1. Reactivity in vanilla JavaScript – use the Proxy pattern to fire events when app state changes. (Frontend Masters course - 'you might not need a framework')

  2. throw new Error("Error!") cannot be used in a ternary (at least not as the 'else' part. The last part of a ternary operator must be an expression, not a function. 'throw' is not an expression, rather it's a statement used to interrupt execution of functions.

  3. A 'stack' in Javascript can be considered a bit like an array, if used in the context of solving problems like you might find on Leetcode. It follows the Last-In-First-Out (LIFO) principle, where elements are added and removed from the same end. Stacks are used to manage function calls, undo functionality etc.

  4. In Javascript any arbitrary number of arguments can be passed to a function. They are accessible via an arguments object which is 'array-like', ie you can use methods such as .length to see how many arguments have been used on the function invocation, for example. (This one is pretty fascinating and well-worth exploring in the console.)

Top comments (0)