December 21, 2022
Estimated Post Reading Time ~

Spread and Rest Operators in JavaScript

 Spread and Rest Operators in JavaScript



1. Spread Operator  
This operator helps to copy all or part of an existing array or object into another array or object  Denoted by the '...' symbol on the right-hand side



2. Example (with Array)




3. Example (with Object)



4. Cloning an Object and Array




5. Merging Arrays and Objects




6. Rest Operator  Rest parameter helps to represent an indefinite number of arguments as an array  Denoted by '...' on the left-hand side



7. Example




8. Use in Functions



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.