Top "Spread-syntax" questions

Please use this tag to refer to "..." in JavaScript.

How to deep merge instead of shallow merge?

Both Object.assign and Object spread only do a shallow merge. An example of the problem: // No object nesting const …

javascript spread-syntax
Deep copy in ES6 using the spread syntax

I am trying to create a deep copy map method for my Redux project that will work with objects rather …

javascript ecmascript-6 redux spread-syntax
Using spread operator to update an object value

I have a function which adds a key to incoming object, but I have been told to use spread operator …

javascript spread-syntax
PHP Spread Syntax in Array Declaration

PHP supports the spread syntax for variadic functions. In JavaScript, you can use the spread syntax to do this: var …

php arrays variadic-functions spread-syntax
JavaScript spread syntax in C#

Is there any implementation in C# like JavaScript's spread syntax? var arr = new []{ "1", "2"//... }; Console.WriteLine(...arr);

javascript c# spread-syntax
Using spread syntax and new Set() with typescript

I am using following code to get unique numbers: let uniques = [ ...new Set([1, 2, 3, 1, 1]) ]; // [1, 2, 3] However, typescript report following error: Type 'Set' …

javascript typescript ecmascript-6 spread-syntax
Javascript ES6 spread operator on undefined

While developing my react App, I needed to send a conditional prop to a component so I found somewhere a …

javascript ecmascript-6 javascript-objects spread-syntax
State as array of objects vs object keyed by id

In the chapter on Designing the State Shape, the docs suggest to keep your state in an object keyed by …

javascript redux spread-syntax
Spread Syntax vs Rest Parameter in ES2015 / ES6

I am confused about the spread syntax and rest parameter in ES2015. Can anybody explain the difference between them with …

javascript ecmascript-6 variadic-functions spread-syntax rest-parameters
Replace array entry with spread syntax in one line of code?

I'm replacing an item in a react state array by using the ... spread syntax. This works: let newImages = [...this.state.…

javascript reactjs spread-syntax