3 ms·
I don't understand how the code snippets are at all equivalent. It looks like ResigsClass doesn't extend anything except Class itself whereas myModel extends Ba
by spicyj 13y ago
I don't understand how the code snippets are at all equivalent. It looks like ResigsClass doesn't extend anything except Class itself whereas myModel extends Backbone.Model which presumably starts off more complicated.
- just2n 13y agoYes. This is precisely the problem. The inheritance model used by Backbone will be significantly more performant in terms of method calls, in general, because it doesn't implement a `super` concept. The construction should also favor Backbone's model since it doesn't create the function wrappers (in the non-trivial case, anyway). Look at what Backbone's `extend` does: https://github.com/documentcloud/backbone/blob/master/backbone.js#L1530 https://github.com/documentcloud/backbone/blob/master/backbo... The subclass's constructor calls the parent's constructor function, just as in Resig's, however Resig's `Class` is: this.Class = function(){}; Whereas `Backbone.Model` looks like this: https://github.com/documentcloud/backbone/blob/master/backbone.js#L246 https://github.com/documentcloud/backbone/blob/master/backbo... It's not hard to predict the outcome of this "benchmark."