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
This article is written by plus2net.com team.
plus2net.com