JavaScript Array fill()

The JavaScript array fill() method is used to fill elements into an array with static values.

Syntax:

array.fill (value, start, end)

Parameters:
value: It represents a static value that has to be filled. It is required.
start: It represents the index from where the value starts filling. The default is 0. It is optional.
end: It represents the index where the value stops filling. The default is array.size-1. It is optional.

Returns:
Modified Array.

Example:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
var a = ["GOLD","SILVER","DIAMOND","RUBY","PLATINUM"]
var result=a.fill("BRONZE",1,4);
document.writeln(a);
</script>
</body>
</html>