Skip to content

Instantly share code, notes, and snippets.

@botmaster
Created November 8, 2013 10:52
Show Gist options
  • Save botmaster/7369402 to your computer and use it in GitHub Desktop.
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
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