create a array in JavaScript having every element Zero

 

Array.prototype.fill()

 

JavaScript fill() method fills method put a static value on each index of array.

 

JavaScript fil() method Syntax 

fill(value)
fill(value, start)
fill(value, start, end)

 

here is the example of javascript fill method

const arr = [6];
	arr.fill(0);

Tags:

Share:

Related posts