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 :
array.valueOf()
Example of Array valueOf() method : In this example I will show how to create a copy of an array.
<!DOCTYPE html>
<html>
<body>
<p>To make a copy of an array, click the button "copy".</p>
<button onclick="copyArray()">copy</button>
<p id="container"></p>
<script>
function copyArray() {
var students = ["Rajesh", "Pankaj", "Sumit", "Manish", "Pramod"];
document.getElementById("container").innerHTML = students.valueOf();
}
</script>
</body>
</html>
Output :
Rajesh,Pankaj,Sumit,Manish,Pramod
0 Comment(s)