Skip to content

Instantly share code, notes, and snippets.

@emkay
Created November 17, 2011 21:43
Show Gist options
  • Select an option

  • Save emkay/1374629 to your computer and use it in GitHub Desktop.

Select an option

Save emkay/1374629 to your computer and use it in GitHub Desktop.
Inheritance
// use Person as a constructor
function Person(name, age) {
this.name = name;
this.age = age;
}
var student = new Person('mike', 29);
Person.prototype.sayHello = function () {
alert('Hello my name is ' + this.name);
};
console.log(student);
student.sayHello();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment