jskatas.org Continuously Learn JavaScript. Your Way.

Array API: array.values()

Array.prototype.values() returns an iterator for all values in the array

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.values returns an iterator for all values in the array

  • values() returns an iterator
  • use iterator.next() to drop first value
  • empty array contains no values
  • a sparse array without real values has values though
  • also includes holes in sparse arrays