Javascript Array longestElement()

Description

Javascript Array longestElement()



Array.prototype.longestElement = function()
{
    var maxLength = 0;

    for(var i = 0 ; i < this.length ; i++)
    {//from   w ww  .  java2 s.  c  om
        if(this[i].toString().length > maxLength)
        {
            maxLength = this[i].toString().length;
        }
    }

    return maxLength;
}



PreviousNext

Related