1 2 3 4 5 6 7 8 9 10 11 12 13 14
function hello() { console.log("Hello, world!"); } function Robot(name) { var ret = {}; ret.name = name; ret.prototype.hello = hello; return ret; } var james = new Robot("James"); james.hello();