Looking to copy a class or object. Is there an ES6 equivalent of angular.extend()
?
Looking to convert an existing angular controller to es6 but didn't want to couple it to angularian implementations.
Looking to copy a class or object. Is there an ES6 equivalent of angular.extend()
?
Looking to convert an existing angular controller to es6 but didn't want to couple it to angularian implementations.
Its called Object.assign
:
The important thing to remember is that it overwrites the first object you pass in, so if you don't want to mutate the original object, pass in an empty object as the first parameter:
var obj = {a:1};
var obj2 = {b:2, c:3};
var obj3 = Object.assign(obj, obj2);