Remove an item from a given array, this does not remove duplicates! - Node.js Array

Node.js examples for Array:Remove Element

Description

Remove an item from a given array, this does not remove duplicates!

Demo Code


ArrayUtils.removeFromArray = function (item, array) {
    var index = array.indexOf(item);
    //from w ww . j av a 2 s.c o  m
    if (index > -1) {
        array.splice(index, 1);
        return true;
    }
    else 
        return false;
};

Related Tutorials