Created
February 11, 2014 18:27
-
-
Save EnoF/8940949 to your computer and use it in GitHub Desktop.
Protected in EnoFJS
This file contains 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 Animal = clazz(function Animal(){ | |
this.protected = { | |
name: 'animal' | |
}; | |
this.public = { | |
sayHello: function sayHello(){ | |
return 'Hi, my name is ' + this.protected.name + '!'; | |
} | |
}; | |
}); | |
var Dog = clazz(function Dog(){ | |
this.extend = 'Animal'; | |
this.public = { | |
sayHello: function sayHello(){ | |
return 'Hello, my name is ' + this.protected.name + '!'; | |
} | |
}; | |
}); | |
var dog = new Dog(); | |
dog instanceof Animal; //True | |
dog.sayHello(); //Hello, my name is animal! | |
dog.name; //undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment