function Person(name) { this.Name = name; this.sayHello = function () { alert('Hello there, I\'m ' + this.Name); }; } function Student(name) { var that = new Person(name); that.codeWith = function (code) { alert(name + ' code with ' + code); }; return that; } var mike = new Student('Mike'); mike.sayHello(); mike.codeWith('JS');