Below is the example of Array valueOf() method.
- Example:
<script>function func() {// Original arrayvar array = ["GFG", "Geeks", "for", "Geeks"];// Checking for condition in arrayvar value = array.valueOf();document.write(value);}func();</script>chevron_rightfilter_none - Output:
GFG,Geeks,for,Geeks
The arr.valueOf() method in JavaScript is used to return the array. It is a default method of the Array Object. This method returns all the items in the same array. It will not change the original content of the array. It does not contain any parameter values.
Syntax:
array.valueOf()
Parameters: This method does not accept any parameter.
Return Value: It returns an Array.
Below examples illustrate the JavaScript Array valueOf() method:
- Example:
var array = ["DS", "Algo", "PHP", "JS", "OS"]; var value = array.valueOf(); document.write(value);
Output:
DS,Algo,PHP,JS,OS
Example codes for the above method are as follows:
Example:
<!DOCTYPE html> <html> <head> <title> JavaScript Array valueOf() Method </title> </head> <body style="text-align:center;"> <h1 style="color:green"> GeeksforGeeks </h1> <h2>JavaScript Array valueOf() Method</h2> <button onclick="myGeeks()">Click me</button> <p id="sudo" style="font-size:20px;"></p> <script> function myGeeks() { var sub = ["DS", "Algo", "PHP", "JS", "OS"]; document.getElementById("sudo").innerHTML = sub.valueOf(); } </script> </body> </html> |
Output:

Supported Browsers: The browsers supported by JavaScript Array valueOf() Method are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
Recommended Posts:
- JavaScript Number valueOf( ) Method
- JavaScript Boolean valueOf() Method
- JavaScript Date valueOf() Method
- JavaScript string.valueOf() Method
- JavaScript | BigInt.prototype.valueOf() Method
- JavaScript | symbol.valueOf() function
- TypeScript | String valueOf() Method
- TypeScript Number valueOf() Method
- Lodash _.prototype.valueOf() Method
- Moment.js moment().valueOf() Function
- How to compare two JavaScript array objects using jQuery/JavaScript ?
- How to move an array element from one array position to another in JavaScript?
- How to get the elements of one array which are not present in another array using JavaScript?
- What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
- How to check whether an array is subset of another array using JavaScript ?
- How to convert Integer array to String array using JavaScript ?
- Difference between array.size() and array.length in JavaScript
- What is the difference between Array.slice() and Array.splice() in JavaScript ?
- How to convert Object's array to an array using JavaScript ?
- JavaScript Course | Understanding Code Structure in JavaScript
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


