clone :: Object

Object.clone(obj) -> Object Clones the passed object using shallow copy (copies all the original’s properties to the result).

Do note that this is shallow copy, not deep copy.

Examples

var o = { name: 'Prototype', version: 1.5, authors: ['sam', 'contributors'] };

var o2 = Object.clone(o);

o2.version = '1.5 weird';

o2.authors.pop();

o.version

// -> 1.5

o2.version

// -> '1.5 weird'

o.authors

// -> ['sam'] // Ouch! Shallow copy!

Prototype API 1.5.0 - prototypejs.org