jskatas.org Continuously Learn JavaScript. Your Way.

Array API: array.fill()

Array.prototype.fill() can fill up an array with one value.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

Array.prototype.fill can fill up an array with one value

  • fill(0) will populate 0 into each array element
  • fill only changes content, adds no new elements
  • second parameter to fill() is the position where to start filling
  • third parameter is the position where filling stops


A discussion in a github issue, about how to use this kata.
API doc on MDN.