Skip to content

Instantly share code, notes, and snippets.

@marabesi
Created June 5, 2014 11:16
Show Gist options
  • Save marabesi/d1ba13e832ce53e8ac73 to your computer and use it in GitHub Desktop.
Save marabesi/d1ba13e832ce53e8ac73 to your computer and use it in GitHub Desktop.
Understanding the language with objects and prototype
function DebugConsole() {
var consoleElem = document.createElement('div');
consoleElem.id = "debug";
document.body.appendChild(consoleElem);
this.shaded = false;
}
DebugConsole.prototype.displayMsg = function(msg) {
var msgElement = document.createElement('div');
msgElement.appendChild(document.createTextNode(msg));
msgElement.className = 'text-log';
var consoleElement = document.getElementById('debug');
consoleElement.appendChild(msgElement);
this.shaded = !this.shaded;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment