1

Premise

I've inherited some code that uses JS.Class for some of it's classes. That is, these classes are created using new JS.Class({...}). JS.Class implements Ruby's object system in JavaScript, meaning that internally it is rather complex.

I am writing new code that uses Backbone.js Models and Collections. Backbone.js uses the predominant style of JS class inheritance: simple prototype chaining. It's almost identical to the style of Google's Closure library (goog.inherits()) and CoffeeScript (class Foo extends Bar).

My question, directed at anyone with JS.Class experience:

Can I use JS.Class to extend non-JS.Class classes? For example, can I create a JS.Class that extends Backbone.Model? Or goog.gears.BaseStore? (just to choose two examples of classes from common JS libraries)

4

0 回答 0