Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • valueOf() method of JavaScript Array

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 124
    Comment on it

    JavaScript Array valueOf() method : The valueOf() method returns the copy of itself. This is the default method of an array object.

    Syntax of Array valueOf() method :

    1. array.valueOf()


    Example of Array valueOf() method : In this example I will show how to create a copy of an array.

    1. <!DOCTYPE html>
    2. <html>
    3. <body>
    4.  
    5. <p>To make a copy of an array, click the button "copy".</p>
    6. <button onclick="copyArray()">copy</button>
    7. <p id="container"></p>
    8.  
    9. <script>
    10. function copyArray() {
    11. var students = ["Rajesh", "Pankaj", "Sumit", "Manish", "Pramod"];
    12. document.getElementById("container").innerHTML = students.valueOf();
    13. }
    14. </script>
    15.  
    16. </body>
    17. </html>


    Output :
    Rajesh,Pankaj,Sumit,Manish,Pramod

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: