Methods
(static) extend(props) → {function}
Using Leaflet.js's L.Class as a reference. http://leafletjs.com/
Parameters:
Name | Type | Description |
---|---|---|
props |
Object | Generate an extended class from given props. |
Returns:
The constructor of extended class.
- Type
- function
Example
var Extended = Class.extend({
// 'initialize' works as a constructor.
initialize: function(arg) {
this.arg = arg;
},
// props in 'statics' are set as static(class) members.
statics: {
staticFunc: function() {
return 'static method!';
},
staticProp: 'static prop!'
},
// this is a instance method.
func: function() {
return 'instance method! ' + arg;
}
});
// calling static(class) members.
Extended.staticFunc(); // => 'static method!'
Extended.staticProp; // => 'static prop!'
// constructs with arguments (method 'initialize' will be called).
var ex = new Extended('foo bar');
// calling instance member
ex.func(); // => 'instance method! foo bar'