Output array with valueOf() in JavaScript

Description

The following code shows how to output array with valueOf().

Example


<!--from   ww  w  .j  ava  2  s  .c  om-->
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
//creates an array with three strings
var colors = ["red", "blue", "green"];

document.writeln(colors.valueOf()); //red,blue,green

</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Output array with valueOf() in JavaScript
Home »
  Javascript Tutorial »
    Data Type »
      Array
...
Create your own function for sorting in Jav...
Delete an array element in JavaScript
Delete with Array splice() in JavaScript
Display Multi-dimensional array in a HTML t...
Do an alphabetical sort() method on strings...
Fill and populate two dimensional array in ...
Filter an array with a condition in JavaScr...
Get a string of the array elements separate...
Get array element value with index in JavaS...
Get the last element in an Array in JavaScr...
Insert with Array splice() in JavaScript
Integer Array Declaration with initializati...
Join array elements together with string se...
Loop through an array with for statement in...
Loop through array and work on each element...
Map array value in JavaScript
Move data from an Array to another in JavaS...
Output array with toString() in JavaScript
Output array with valueOf() in JavaScript
Push form value to a stack in JavaScript
Push two values to an empty array in JavaSc...
Reduce an array from the end with reduceRig...
Reduce array to a value in JavaScript
Reference array element by random index val...
Remove elements from array by changing the ...
Remove the first item in the array and retu...
Replace array element with Array splice() i...
Reverse an array in JavaScript
Search an array for an object with indexOf ...
Search an array from back at a specific end...
Search an array from start with indexOf met...
Search an array from starting index with in...
Search an array from the end for an object ...
Search an array from the end with lastIndex...
Set array element value with index in JavaS...
Slice an array to get a sub-array in JavaSc...
Slice array with negative value in JavaScri...
Sort Array Based on Argument Lengths in Jav...
...