Rate this script:  I Love it  /   I Hate it

modified prototype's $A function


Code


function $A(iterable)
{
        if (!iterable)
                return []
        if (iterable.toArray)
                return iterable.toArray()
        else if (iterable.constructor == Array)
                return iterable
        else
        {
                var results = []
                if (iterable.constructor == Object)
                        for (var x in iterable)
                                results.push(iterable[x])
                else
                        for (var i = 0, n = iterable.length; i < n; i++)
                                results.push(iterable[i])
                return results
        }
}
 

 

 
modified prototype's $A function scripts | modified prototype's $A function snippet | modified prototype's $A function example | modified prototype's $A function tutorial | modified prototype's $A function code