In cases, where you need to pass elements of an array as the arguments in a function call; the spread syntax can be used to mention arguments one by one
👩🏫 Spread in array literals is a powerful combination. It can be used to
☝️copy an array - one level deep
☝️merge two arrays
☝️create a new array by inserting the existing array at any index
👩🏫 Spread in object literals can be used to create/copy a new object or merge two objects
Follow me - @ojhabhumika28 for more threads, tips and quizzes on JavaScript ✨
• • •
Missing some Tweet in this thread? You can try to
force a refresh
☝️The destructuring expression allows the extraction of properties from objects into distinct variables with the help of a minimum code
📌Check out the thread below to know more
☝️Destructure Syntax for objects
Note: ensure property name and variable name are same while destructuring an object
☝️Default value
- each destructured property can have a default value
- default value can also be any expression
- default value/expression is used when the property is not present or has a value undefined
- not used if the value of a property is null