JavaScript | Array valueOf() Method

The Array 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() 

Return Value: It returns an Array.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


  • Before Clicking on Button:
  • After Clicking on Button:

Supported Browsers: The browsers supported by JavaScript Array valueOf() Method are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.