Extending Object.prototype with TypeScript

I used to have:

// See if an array contains an object
Array.prototype.contains = function (obj) {
    var i = this.length;
    while (i--) {
        if (this[i] === obj) {
            return true;
        }
    }
    return false;
}

in order to make that code compile with typescript I added the line:

interface Array {
    contains(obj: Object): boolean;
}

Thanks basarat!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)