# DestructuringÄestructuring is an easy way to extract items from an object or array. Again, if you aren't sure what this is or when you need it, reading about lexical this first may only confuse you. We won't be covering the lexical this scope with arrow functions in here, but you can Google around if you're still curious. You can create a variable and give it an anonymous arrow function as the value, though (as seen with the doubleAge and filter variables). Unlike the function someFunc() declaration, arrow functions cannot be used to create functions with such syntax.The doubleAge and filter variables are a good example of this. Omitting curly braces will make arrow functions use implicit return, but only if you have a single-line expression.You can cleanly put what you need on a single line without curly braces.If you feel like this will confuse you, it may be a good idea to use parentheses. The parentheses around function parameters are optional when you have only one parameter but are required otherwise.There are a few important things you should note here: Template literals vs string concatenation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |