Old Browsers

If you have to target old browsers, here are some fallbacks for [].indexOf, [].forEach, and [].map:

(function() {
    if (typeof window.console === "undefined") {
        window.console = { log: function() {}, error: function() {} };
    }
    if (typeof Array.prototype.indexOf === "undefined") {
        Array.prototype.indexOf = function(obj, start) {
            for (var i = (start || 0); i < this.length; i++) {
                if (this[i] == obj) {
                    return i;
                }
            }
            return -1;
        };
    }
    if (typeof Array.prototype.forEach !== "function") {
        Array.prototype.forEach = function(action) {
            if (typeof action !== "function") {
                throw new Error("Array.prototype.forEach: argument is not a Function object");
            }
            var i;
            for (i = 0, n = this.length; i < n; ++i) {
                if (i in this) {
                    action(this[i], i, this);
                }
            }
        };
    }
    if (typeof Array.prototype.map !== "function") {
        Array.prototype.map = function(callback) {
            if (typeof callback !== "function") {
                throw new Error("Array.prototype.map: argument is not a Function object");
            }
            var result = [];
            this.forEach(function(currVal, idx, arr) {
                result.push(callback(currVal, idx, arr));
            });
            return result;
        };
    }
})();