As the subject, is it OK to use ...
in that way to copy properties in an object to another?
Chrome always throws syntax error when I was trying to use it in an object like:
var a = function(){
return {c: 2};
}
var b = {...a()};
As the subject, is it OK to use ...
in that way to copy properties in an object to another?
Chrome always throws syntax error when I was trying to use it in an object like:
var a = function(){
return {c: 2};
}
var b = {...a()};
In es2018 the spread syntax if applied to an object behaves like object.assign
.
var obj1 = { a: 1 }
var obj2 = function() { return {b:2} };
var obj3 = { ...obj1, ..obj2 }
The result would be a new object with combine properties of obj1 and obj2. So obj3 would now be { a:1, b2 }
.