I think merge is not semantically correct!
you are simply extracting from o2 using o1 like a template... where' the
merge!?!
At max I could expect from
merge(o1,o2) -> { a:1, b:2, c:3, d:4, e:5 }
merge(o2,o1) -> { a:1.2, b:2.2, c:3.2, d:4, e:5 }
--
-----------
Tafuni Vito
[email protected]
---------------------------------------------
"Verba volant, scripta manent... data corrupted"
2010/11/12 stratboy <[email protected]>
> Hi! Suppose this:
>
> var o1 = { a:1, b:2, c:3 }
> var o2 = { a:1.2, b:2.2, c:3.2, d:4, e:5 }
>
> I want some kind of merge operation that merges only the props with
> same key, so in the end I've got this:
>
> var o3 = { a:1.2, b:2.2, c:3.2 }
>
> I know I can do it with a couple of passages, for ex. by using
> Object.subset first. Though, I'd like to know i there's some other
> smart way. It would quite handy if in the future releases of mootools
> there will be a thing like:
>
> Object.merge(o1,o2[,true]);
>
> where the last option is for using only the common keys or not.
>
> :) How about?
>
>