copy

makes a deep copy of an object/array

object| array copy(object| array source);

Parameters

sourceobject| arraythe source (passed) object/array

Returns

object| arraythe copy of the source object/array

Example

var obj1 = {name:"flower", type:"rose", colors: ['red','pink','white','yellow']  }
var obj2 = webix.copy(obj1);
 
 
obj1.type = 'tulip';
 
obj1.type // -> 'tulip'
obj2.type // -> 'rose'
 
obj2.colors // -> ['red','pink','white','yellow']

Details

Doesn't work for structures with inner loops.

See also
Back to top