Skip to content

Instantly share code, notes, and snippets.

@fellix
Created May 11, 2012 20:00
Show Gist options
  • Save fellix/2662092 to your computer and use it in GitHub Desktop.
Save fellix/2662092 to your computer and use it in GitHub Desktop.
js prototype
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