JSFiddle - React, Tailwind, and code Playground

by dmitri_pavlutin

JavaScript

const array = Array(3);

console.log(isDense(array)); // logs false
console.log(array);          // logs [empty, empty, empty]

function isDense(array) {
  for (let index = 0; index < array.length; index++) {
    if (!(index in array)) {
      return false;
    }
  }
  return true;
}