Created
November 8, 2013 10:52
-
-
Save botmaster/7369402 to your computer and use it in GitHub Desktop.
The following code example shows all eight types of members and methods in one class; it also demonstrates which members are available to the different types of methods, and how they're accessed.
Original post here :
http://smorgasbork.com/index.php?option=com_content&view=article&id=132
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 _privateStaticMember = 'PrSM'; | |
function MyClass () | |
{ | |
var _privateInstanceMember = 'PrIM'; | |
var _privateInstanceMethod = function () | |
{ | |
return _privateStaticMember + ',' | |
+ _privateInstanceMember + ',' | |
+ MyClass.publicStaticMember + ',' | |
+ this.publicInstanceMember; | |
}; | |
this.publicInstanceMember = 'PuIM'; | |
this.publicInstanceMethod = function () | |
{ | |
return _privateStaticMember + ',' | |
+ _privateInstanceMember + ',' | |
+ MyClass.publicStaticMember + ',' | |
+ this.publicInstanceMember; | |
}; | |
} | |
var _privateStaticMethod = function () | |
{ | |
return _privateStaticMember + ',' + MyClass.publicStaticMember; | |
}; | |
MyClass.publicStaticMember = 'PuSM'; | |
MyClass.publicStaticMethod = function () | |
{ | |
return _privateStaticMember + ',' + MyClass.publicStaticMember; | |
}; | |
module.exports = MyClass; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment