function createPerson(){ var o = new Object(); o.sayHello = function(arg){ alert(arg); } return o; } var person1 = createPerson(); person1.sayHello("hello");
function createPerson(name){ var o = new Object(); o.name = name; o.sayName = function(){ alert(this.name); } return o; } var person1 = createPerson("Sprite"); person1.sayName();