2011/10/7 John-David Dalton <[email protected]> > > As for the functionality, it should just be an n-ary function which > extends > > the first object with all the _own_ properties of the other n-1 objects. > If > > keys clash give right precedence. > > I've used this flavor of extends too (minus the own properties part). >
I also think this is the way to go. Object.extend should copy only own properties, though. Other use cases can be dealt with by creating a small abstraction to copy properties recursively. Or by providing a native .deepExtend. I'd assume the majority of the use-cases wouldn't want to deal with copying all descriptors -- taking into account we're not copying just enumerables here, it could well be a problem -- since it'd bring in too much overhead in each call. > > whether key clashes favour left or right isnt important. whether the > return > > value is undefined or the first object isnt important. > > Yap but chaining FTW. > I think Object.extend should return the target object. It makes no sense to do otherwise -- considering the majority of JS native API either returns an useful value, and most of them are pure. By the way, what are your thoughts on pure vs destructive Object.extend?
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

