May 12, 2010

adding a new memeber to all objects in javascript

function Person(){}

var root = Object.prototype;
root.say = function () { alert("hi"); }
  
Person.say();
var p = new Person();
p.say();