﻿///
/// var a = new Array();
/// a.indexOf('a', 1);
if (!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(obj, fromIndex) {
        if (fromIndex == null) {
            fromIndex = 0;
        } else if (fromIndex < 0) {
            fromIndex = Math.max(0, this.length + fromIndex);
        }
        for (var i = fromIndex, j = this.length; i < j; i++) {
            if (this[i] === obj) return i;
        }
        return -1;
    };
}

///
/// var string = "Hello {0}!".format('David');
if (!String.prototype.format) {
    String.prototype.format = function() {
        var pattern = /\{\d+\}/g;
        var args = arguments;
        return this.replace(pattern, function(capture) { return args[capture.match(/\d+/)]; });
    };
}

///
/// var string = 'Hello   '.trim();
if (!String.prototype.trim) {
    String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
}
