Created
July 6, 2010 12:00
-
-
Save ismasan/465295 to your computer and use it in GitHub Desktop.
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
/* Javascript classes, prototypes and method visibility | |
--------------------------------------------------------------*/ | |
// Simple, prototype-less class | |
var Makoto = function(name){ | |
function privateMethod(){ | |
return 1; | |
} | |
this.pMethod = function(){ | |
return privateMethod() | |
} | |
} | |
// Complex, prototype + private methods | |
var Abstract = function(){} | |
Abstract.prototype = {} | |
var Olly2 = (function(){ | |
function privateMethod(){ | |
return 1; | |
} | |
var klass = function(name){ | |
} | |
klass.prototype = new Abstract | |
klass.prototype.hello = function(){ | |
return privateMethod() | |
} | |
return klass; | |
})(); | |
o = new Olly2('Olly') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment