I am curious to create an MVC javascript framework for fun and as a learning experience.
Inside backbone.js https://github.com/jashkenas/backbone/blob/master/backbone.js, the author uses the underscore method _.extend()to "expand" the base object.
Starting with Model, I'm trying to figure it out.
_.extend(Model.prototype, Events, {});
How it works? Modelalready defined before, then the author wants Copy all of the properties in the source objects over to the destination object http://underscorejs.org/#extend , does he create a whole bunch of methods inside to interact with the original model as a prototype?
Why not do
Backbone.Model.prototype.get = function() {
return 'Do Get';
}
Backbone.Model.prototype.set = function() {
return 'Do Set';
}
Or is it even better to use Es6? Is the following even the same as the one above?
class Model extends Backbone {
get() {
return 'Do Get';
}
set() {
return 'Do Set';
}
}
, - ? , , es6 -, , .
- .