What is equivalent to jQuery $ .extend () in Ember.js?

I used cloning a variable in jquery as follows:

var clone = $.extend(true, {}, orig); 

Is there any method in Ember.js that is equivalent to this?

+7
javascript jquery clone
source share
2 answers

Yes there is: Ember.copy

 var clonedObj = Ember.copy(originalObj, true); 
+11
source share

This is like my least favorite named method in jquery. Each time I want to combine two objects, it takes me a few seconds to think about what he called. You can also use assign in Ember.

 Ember.assign({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'} var a = {first: 'Yehuda'}, b = {last: 'Katz'}; Ember.assign(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'} 

or in your case

 Ember.assign({}, orig); 

http://emberjs.com/api/classes/Ember.html#method_assign

But, you should note that it does not support deep cloning, as the copy does.

+16
source share

All Articles