var Human = (function (person) {
this.firstName = "John";
this.lastName = "Doe";
this.age = person.age || 50;
this.eyeColor = person.eyeColor || "blue";
this.toString = function() {
return person.age + ", " + person.eyeColor;
};
});
var pers = new Human({ eyeColor: "Yellow" });
//
console.log(pers);
Выглядеть в конечном итоге это может как-то так:
var SampleClass = (function(localFirstDependencyName, localSecondDependencyName){
'use strict';
var _defaultSettings = {
option: 'option'
}
var constructor = function(settings){
this._settings = $.extend(this._settings || {}, _defaultSettings, settings);
this.publicField = null;
this._protectedField = null;
this._privateField = null;
};
$.extend(constructor.prototype, {
publicConstant: 'Constant',
protectedConstant: 'Constant',
_privateConstant: 'Constant',
//#region Public
publicMethod: function () {
this._protectedMethod();
},
//#endregion
//#region Protected
_protectedMethod: function () {
},
//#endregion
//#region Private
_privateMethod: function(self, value){
},
//#endregion
});
return constructor;
}(globalFirstDependencyName, globalSecondDependencyName));