@Aaron: Thanks for the clarification. Out of curiosity, knowing there would be a collision here, why not use a different name for the Array.clone method (since it was introduced later than the Element.clone method)?
@Sanford: Interesting, did you clone DocumentFragments or existing DOM elements? The actual use case for my original question is that I built a DataModel class which takes in arbitrary functions for "exporting" a model. The class has no idea what the function generates and I dont want to build any logic that sniffs the results to see if the output is a Collection or something else. The real problem arises as the class caches the results of the export function. On Feb 28, 2:51 pm, Sanford Whiteman <[email protected]> wrote: > Just wanted to add that, per some timings I just re-ran, new Element() > is still more than 3x faster than Element.clone(). > > Which means, from a performance standpoint, that if you initially > build an element from a known template of {} options and are just > trying to get more of the same, it is far better to rebuild from the > template than to clone. > > This does not address convenience factors or other needs that make > cloning more suitable... just something else to think about. > > -- S.
