Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript features I'd like to remember and use more often #21

Open
shreshthmohan opened this issue Mar 19, 2022 · 0 comments
Open

JavaScript features I'd like to remember and use more often #21

shreshthmohan opened this issue Mar 19, 2022 · 0 comments

Comments

@shreshthmohan
Copy link
Owner

shreshthmohan commented Mar 19, 2022

The arguments object and ...rest parameters syntax

  • Especially useful when you don't know the number of arguments in a function
  • Or when destructing an object and you want the remaining properties in a separate object
  • Prefer rest parameters when writing ES6
  • One advantage of using ...rest syntax for function arguments is that the result will be an actual array, unlike arguments, which is an array-like object. The latter doesn't have built-in array methods like .map() and such.

for...of loop

  • to iterate over values in an iterable.
  • don't use for...in (Note that it's for a different purpose and can cause unexpected problems, TODO demo these problems)

getters and setters

TODO code example

Use Object.entries() to get all values in an array.

@shreshthmohan shreshthmohan added the draft A blog post that is a draft label Sep 6, 2022
@shreshthmohan shreshthmohan added status:published and removed draft A blog post that is a draft labels Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant