Javascript Array get(i)

Description

Javascript Array get(i)


/**//www  . ja  v a 2  s . c om
 * Array element accessor supporting negative indices,
 * as with jQuery objects and most Python sequence types.
 */
Array.prototype.get = function(i)
{
    if (i < 0)
    {
        return this[this.length + i];
    }
    else
    {
        return this[i];
    }
};



PreviousNext

Related