Home >Web Front-end >JS Tutorial >What I learned last week (

What I learned last week (

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-09-25 18:53:22707browse

What I learned last week (

  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.)

The above is the detailed content of What I learned last week (. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn