Javascript Array asEnumerable()

Description

Javascript Array asEnumerable()



Array.prototype.asEnumerable = function () {
    var enumerable = Enumerable.from(this);
    enumerable.remove = remove.bind(this);
    enumerable.removeAll = removeAll.bind(this);
    return enumerable;
};

function remove(item) {
    var i = this.indexOf(item);
    this.splice(i, 1);//from w  ww  .  j  a v a2  s.co  m
}

function removeAll() {
    var self = this;

    while (self.length != 0) {
        self.shift();
    }

    return this;
}

window.isArray = function (obj) {
    return Object.prototype.toString.call(obj) === '[object Array]';
};



PreviousNext

Related