Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // example using constructor function
- function Person (name, age) {
- this.name = name;
- this.age = age;
- }
- Person.prototype.greet = function () {
- console.log('Hello, I\'m ' + this.name)
- }
- var man = new Person("dude", 23);
- // example using obj literal as prototype
- var Human = {
- name: null,
- age: null,
- location: null
- }
- Human.greet = function () {
- console.log("Hello, I'm " + this.name)
- }
- var woman = Object.create(Human)
Advertisement
Add Comment
Please, Sign In to add comment