JavaScript Prototype add-ons

I know a lot of people disagree with adding onto the prototype for built in JavaScript objects but... I'm not one of them. I find them very useful. In the below examples the code will only be executed if there is not an existing method.

Anyway, if you are interested, here are a few that I use:

Strings

String.prototype.trim || (String.prototype.trim = function () {
    return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
}),

String.prototype.toProperCase || (String.prototype.toProperCase function () {
    return this.toLowerCase().replace(/^(.)|\s(.)/g, function (t) {
        return t.toUpperCase();
    });
}),

String.prototype.pad || (String.prototype.pad = function (t, e) {
    for (var o = this, r = e ? e : "0", n = t ? t : 2; o.length < n;) o = r + o;
    return o;
}),

String.prototype.startsWith || (String.prototype.startsWith = function (t) {
    return this.match("^" + t) === t;
}),

String.prototype.has || (String.prototype.has = function (t) {
    return this.indexOf(t) > -1;
}),

String.prototype.endsWith || (String.prototype.endsWith = function (t) {
    return this.match(t + "$") === t;
}),

String.prototype.replaceAll || (String.prototype.replaceAll = function (t, e, o) {
    var r, n = this + "", i = -1;
    if ("string" == typeof t) {
        if (!o) return this.split(t).join(e);
            for (r = t.toLowerCase(); - 1 !== (i = n.toLowerCase().indexOf(t, i >= 0 ? i + e.length : 0));) n = n.substring(0, i) + e + n.substring(i + t.length); }
    return n;
});

Functions

Function.prototype.curry || (Function.prototype.curry = function(){
    function toArray(vals) {
          return Array.prototype.slice.call(vals);
    }
    if (arguments.length<1) {
      return this; //nothing to curry with - return function
    }
    var __method = this;
    var args = toArray(arguments);
    return function() {
      return __method.apply(this, args.concat(toArray(arguments)));
    };
}),

Function.prototype.compose || (Function.prototype.compose = function( argFn ){
    var invokingFunction = this;
    return function() {
        return invokingFunction.call(this,argFn.apply(this,arguments));
    };
});

There you go! 'Til next time.