Hey everyone, do you think this is okay javascript? Anyone ever done something like this before?
[code]
function Person() { }
Person.prototype.sayHi = function() { alert(“Hello!”); }
var myperson = {id: 3004, name: “Goobles”};
myperson.prototype = Person.prototype;
myperson.sayHi();
I’ve never changed the prototype manually. I’m experimenting with it because JSON just returns everything as plain Objects. I need the JSON to return Persons so I can call sayHi on them, but the only way I can think of doing that is to change the prototype.
Tried googling, but all that came up was the Prototype framework. Wish they named their framework differently.
PS. Sorry for the double-post, I was trying to edit the title and something weird happened.