valueOf() : displaying elements

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.
Here is a sample code.
<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 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 
Your Rating





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-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer