valueOf() : displaying elements

<script>
var scripts = new Array();
scripts[0] = "PHP";
scripts[1] = "ASP";
scripts[2] = "JavaScript";
scripts[3] = "HTML";

document.write(scripts.valueOf());
</script>
The output is here
PHP,ASP,JavaScript,HTML
We can get all elements of an array by using valueOf(). The elements will be separated by comma. These are the primitive values of the array.

We can add another array to this
<script type="text/javascript">
servers= new Array('Apache', 'IIS');

var scripts = new Array();
scripts[0] = "PHP";
scripts[1] = "ASP";
scripts[2] = "JavaScript";
scripts[3] = "HTML";
scripts[4] = servers;
document.write(scripts.valueOf());

</script>
Output is here
PHP,ASP,JavaScript,HTML,Apache,IIS 
Removing all elements of an array
Array Reference How to display elements of an Array
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer