The JavaScript Array toString() Method returns the string representation of the array elements
arr.toString()
Parameters: This method does not accept any parameter.
Return value:
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
<script>
var a = ["Rahul","Karan","Aman","Neha"];
a.toString();
document.write(a + "<br><br>");
</script>
</head>
<body>
</body>
</html>
The JavaScript 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.
array.valueOf()
Parameters: This method does not accept any parameter.
Return Value: It returns an Array.
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
<script>
var a = ["Rahul", "Karan", "Aman", "Neha"];
document.write(a.valueOf() + "<br><br>");
</script>
</head>
<body>
</body>
</html>
The fill()
method fills specified elements in an
array with a value.
The fill()
method overwrites the original array.
Start and end position can be specified. If not, all elements will be filled.
array.fill(value, start, end)
Parameter | Description |
value |
Required. The value to fill in. |
start |
Optional. The start index (position). Default is 0. |
end |
Optional. The stop index (position). Default is array length. |
Type | Description |
Array | The filled array. |
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
<script>
var a = ["Rahul", "Karan", "Aman", "Neha"];
a.fill("Ram");
document.write(a);
</script>
</head>
<body>
</body>
</html>