Skip to content

Instantly share code, notes, and snippets.

@eightbitraptor
Forked from mikespokefire/my_class.js
Created November 13, 2013 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eightbitraptor/7447231 to your computer and use it in GitHub Desktop.
Save eightbitraptor/7447231 to your computer and use it in GitHub Desktop.
"use strict";
var MyClass = (function() {
function MyClass(publicString) {
this.publicString = publicString;
};
var privateString = "I'm a private string that can't be accessed directly";
// ============================================================================
//
// CLASS METHODS
//
// ============================================================================
MyClass.bar = function() {
console.log(helpMe());
return 'bar';
};
// ============================================================================
//
// INSTANCE METHODS
//
// ============================================================================
MyClass.prototype.foo = function() {
console.log(helpMe());
return 'foo';
};
return MyClass;
// ============================================================================
//
// PRIVATE HELPER METHODS
//
// ============================================================================
function helpMe() {
console.log(privateString);
return "I'm a private helper, I can't be accessed directly";
};
})();
var c = new MyClass('a public string');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment