How can I use JQuery $.extend in Angular2 without using Jquery?
I try to use Object.assign but deep merging does not work.
An example here: https://codepen.io/anon/pen/NvGPOv
Object.assign( baseOptions, customOption);
How can I use JQuery $.extend in Angular2 without using Jquery?
I try to use Object.assign but deep merging does not work.
An example here: https://codepen.io/anon/pen/NvGPOv
Object.assign( baseOptions, customOption);
Angular 2/4 does not provide any way to perform deep copy. It does not offer any opinion or implementation on deep copy of Javascript objects.
If your object does not contain functions or date objects then the below approach using pure Javascript way can work for you in most cases:
var clonedObject = JSON.parse(JSON.stringify(obj));
Once the object is cloned, you can assign additional properties to it.