merge :: Hash

merge(hash) -> alteredHash Injects all the pairs in the given hash into the current one, which is then returned.

Duplicate keys will cause an overwrite (the argument hash prevails), and new keys from the argument hash are also used. This is useful for selectively overwriting values on specific keys (e.g. exerting some level of control over a series of options).

Note the argument needs not be a Hash object, as it it will get passed to the $H function anyway, to ensure compatibility.

Examples

var h = $H({ name: 'Prototype', version: 1.5 });

h.merge({ version: '1.5 final', author: 'Sam' });

h.invoke('join', ' = ').sort().join(', ')

// -> "author = Sam, name = Prototype, version = 1.5 final"

Prototype API 1.5.0 - prototypejs.org