Spread operator in JavaScript version ES2015 lets you explode array elements into arguments. That can be very useful when creating a new array consisting of all elements from another array ((so that you don’t mutate the latter)) or when calling a function with arguments that are in array ((equivalent to calling a function with .apply
method)).
Spread operator is only supported in Chrome, Firefox, IE Edge and Safari.
Lately I’ve been using the following snippet:
console.log(...todos)
where variable todos
in an array of objects. Result? Now in Chrome console I don’t have to expand objects to see if the attributes are set right because console.log is printing every object with every attribute/value inside, not just Object.