JSFiddle - React, Tailwind, and code Playground
JavaScript
const a = ['1', '2', '3'];
const i = 5;
a[i] = '4';
console.log(a); // (6) [ "1", "2", "3", empty x 2, "4" ]
// Array(6) [ "1", "2", "3", <2 empty slots>, "4" ]
a[i-1] = undefined;
console.log(a); // (6) [ "1", "2", "3", empty, undefined, "4" ]
// Array(6) [ "1", "2", "3", <1 empty slot>, undefined, "4" ]
console.log(a.hasOwnProperty(i-2)); // false
console.log(a.hasOwnProperty(i-1)); // true