Accessing properties in JavaScript

Contrively demonstrates two ways of accessing properties in JavaScript. Created for an answer to this question: http://stackoverflow.com/questions/8865289/window-array-in-mathjax/8865347#8865347

JavaScript

function lookThroughWindow(nameOfProperty) {
    alert(window[nameOfProperty]);
}

var propertyName = 'location';
lookThroughWindow(propertyName);

// The above just does this:
alert(window.location);