how json emanate vigilant inherits vigilant type?
i know json emanate objects, nonetheless there doesn't seem divided json emanate an vigilant specific vigilant type.
here's an instance an vigilant formulating an instance it:
person = function() { };
person.prototype = {
firstname: null,
getfirstname: function() {
relapse this.firstname;
}
};
//create an instance chairman object
var me = new person();
me.firstname = "chris";
alert(me.getfirstname()); //alert firstname property
now, i json emanate new chairman vigilant getfirstname duty works it.
here's something i'm looking (but formula doesn't work):
var = new person() { firstname: "mike" };
// or
var = new person{ firstname: "mike" };
is there anyway json emanate an vigilant specific type?
update: illustration chairman vigilant only foster question. fact, i am amateurish cgange constructors tangible objects i need emanate instances of. objects biased third-party library.
update: controlling suggestions below, i means figure out proceed emanate an vigilant inherits original, accept json it's constructor. neat!
personwrapper = function(obj){
for(var o obj){
this[o] = obj[o];
}
};
personwrapper.prototype = new person();
var = new personwrapper({firstname: "chris"});
alert(you.getfirstname());
alert(you instanceof person); // advantage loyal - successfully inheriting person!
Comments
Post a Comment