Skip to content

Instantly share code, notes, and snippets.

@bripkens
Created November 24, 2012 06:15
Show Gist options
  • Save bripkens/4138636 to your computer and use it in GitHub Desktop.
Save bripkens/4138636 to your computer and use it in GitHub Desktop.
'JavaScript, State of the Art' article series: simple function example
// JSFiddle: http://jsfiddle.net/qQk7v/
var addMessage = function(message) {
var isWindowScope = window === this,
extendedMessage = message + ' (called with window context: ' + isWindowScope + ')',
textNode = document.createTextNode(extendedMessage);
document.body.appendChild(textNode);
};
addMessage('Welcome to: ' + location);​
// Renders the following in the body:
// Welcome to: <location> (called with window context: true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment