, , , , , JS.
, :
var Lasher;
(Lasher = function (opts) {
this._name = opts.name;
}).prototype = Object.create(Object.prototype, {
_name: { writable: true },
name: { get: function() { return this._name; }},
});
, , -, @Bergi , . -, , , ( , ). , . , () Lasher, prototype, - ( ).
, , . , Lasher ( ).
, . , :
(function Crasher(opts) {
this._name = opts.name;
}).prototype = Object.create(Object.prototype, {
_name: { writable: true },
name: { get: function() { return this._name; }},
});
, . Crasher () , Crasher , .
, Lasher , Masher () . , ().
, , Object.create , , , , JS . , Function , , , Object.create. .
, , , Object.create . , :
var Masher = function(){ console.log("default");};
Masher.prototype = Object.create(Object.prototype, {
_name: { writable: true },
name: { get: function() { return this._name; }},
constructor: { value: function(opts) {
console.log("ctor");
this._name = opts.name;
return this;
}}
});
, , / JS, , .