Created
May 19, 2011 15:06
-
-
Save kaaes/980967 to your computer and use it in GitHub Desktop.
Watch out for context part 1
This file contains hidden or 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
// create Logger constructor with few properties | |
var Logger = function(id) { | |
this.container = document.getElementById(id); | |
this.counter = 0; | |
} | |
// add functionalities with prototype | |
Logger.prototype.log = function(msg) { | |
this.container.innerHTML = msg ; | |
this.counter++; | |
} | |
Logger.prototype.getCounter = function() { | |
this.log(this.counter); | |
} | |
// create new logger object and log few messages | |
var logger = new Logger('logger'); | |
logger.log('wow'); | |
logger.log('plum'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment