Created
May 11, 2012 20:00
-
-
Save fellix/2662092 to your computer and use it in GitHub Desktop.
js prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Nohup; | |
Nohup = {}; | |
Nohup.Person = function Person(){ | |
var init = function(name, age){ | |
this.name = name; | |
this.age = age; | |
}; | |
var Person = function(){ | |
init.call(this, arguments[0], arguments[1]); | |
}; | |
Person.prototype.canDrive = function(){ | |
return this.age >= 16; | |
} | |
return Person; | |
} | |
var Person = Nohup.Person(); | |
var felix = new Person("Rafael Felix", 24); | |
console.log(felix); | |
console.log(felix.canDrive()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment