Add methods to object example.
by wilt
JavaScript
var object = {
name: "object name",
description: "object description",
properties: [
{ name: "first", value: "1" },
{ name: "second", value: "2" },
{ name: "third", value: "3" }
]
};
SmartObject = function( object ){
this.name = object.name;
this.description = object.description;
this.properties = object.properties;
}
SmartObject.prototype.getName = function(){
return this.name;
}
SmartObject.prototype.getDescription = function(){
return this.description;
}
SmartObject.prototype.getProperies = function(){
return this.properties;
}
var smartObject = Object.assign( Object.create( SmartObject.prototype ), object );
console.log( smartObject );