As far as coding in a functional paradigm is concerned, using the spread syntax in ES6 can prove to be heavily beneficial. The spread syntax can be easily used to create copies of arrays or objects. Using spread syntax in a program does not need to resort to Object.create, slice or any library function. The spread syntax is widely used in Redux and rx.js projects.

While on the other hand, the rest syntax feature of ES6 is used to pass an arbitrary number of arguments to a function. It can also be considered as a shorthand in JavaScript programming. Rest syntax can be considered as the opposite of spread syntax. It takes data and stuffs it into an array instead of unpacking the data. In addition to that, it works suitably in function arguments, arrays as well as to object destructuring assignments.

Note: This question is asked in almost all ES6 Interview Questions.

Suggest An Answer

No suggestions Available!