12 ms·
Backbone's 'extend' is portable to non-Backbone classes[1]. It would be more interesting to see the performance profile comparison of Backbone and Resig impleme
by cdata 13y ago
Backbone's 'extend' is portable to non-Backbone classes[1]. It would be more interesting to see the performance profile comparison of Backbone and Resig implementations of extend when used to inherit from the same class (either an empty class, or a Backbone class).
[1] https://github.com/documentcloud/backbone/blob/master/backbone.js#L1530-L1561 https://github.com/documentcloud/backbone/blob/master/backbo...
- reissbaker 13y agoI was also bothered by the fact that the two were instantiating very different objects, so I forked the tests and added a new case that uses Backbone's portable extend method to create vanilla objects: http://jsperf.com/backbone-vs-john-resig-class/5 http://jsperf.com/backbone-vs-john-resig-class/5 TL;DR: the Backbone approach has similar performance characteristics compared to Resig's when instantiating similar objects. In some browsers (Firefox Nightly, Safari), Backbone's approach is significantly faster. It's also compatible with strict mode — although Backbone itself doesn't use strict mode — whereas Resig's uses arguments.callee which will throw errors.