$.extend with some condition in jquery -


how use $.extend condition?

obj=[{..}, {..}, {....}];  this.model.axes=[{..}, {..}, {...}];  $.extend(true, this.model.axes, obj); 

obj array of json object , same this.model.axes. want extend or merge values obj model.axes skip first 2 indexes. means no need merge values this.model.axes[0] , this.model.axes[1] obj[0] , obj[1].

i want merge obj[0] this.model.axes[2] , obj[1] this.model.axes[3] that.

how can skip first 2 json objects model.axes?

thanks,

siva

if want concatenate obj array this.model.axes without first 2 elements of this.model.axes, following you:

this.model.axes = this.model.axes.slice(2).concat(obj); 

(demo)

if want replace values of this.model.axes values of obj starting @ third element of this.model.axes, use following:

this.model.axes = this.model.axes.slice(0, 2).concat(obj); 

(demo)

finally, if want extend objects in arrays beginning third element of this.model.axes , continuing until last element of obj, want following:

for (var = 0; < obj.length; += 1) {     if (obj[i]) {         $.extend(true, this.model.axes[i + 2], obj[i]);     } } 

(demo)


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -