Javascript Arrays Builtin Functions List Reference

The following are some important standard functions that can be used only with arrays:

Javascript toString() Function:
This function converts an array to a string. Comma is used as a separator of the array elements.

Javascript join(seperator) Function:
This function is same as the toString() function. It converts an array to a string, but the seperator string separates the array elements.

Javascript sort() Function:
This function sorts the contents of an array based upon the ASCII value.

Javascript reverse() Function:
This function reverses the contents of an array. The last element becomes first and the first elements becomes last.

The basic syntax for using the above function is as follows:

Complete Code Example on using above functions:

<script type="text/javascript">
    document.write("<h1>List of builtin javascript array functions</h1><hr/>");
    var favColor = new Array(4)
    favColor[0] = "White"
    favColor[1] = "Red"
    favColor[2] = "Green"
    favColor[3] = "Yellow"
    document.write("favColor.toString() : " + favColor.toString() + "<br/><br/>");
    document.write("favColor.join('') : " + favColor.join('') + "<br/><br/>");
    document.write("favColor.reverse() : " + favColor.reverse() + "<br/><br/>");
    document.write("favColor.sort() : " + favColor.sort() + "<br/><br/>");


Download Code Example Javascript Built in Functions

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code