โฌ Holes are indices โinsideโ an Array that have no associated element.
โฌ An array with at least a single hole in it is called a "Sparse Array".
โฌ An array without any hole is called a "Dense Array".
โ How to detect a hole?
Check if
โฌ 0 โค index < Array's length
โฌ index is not in the array
Example:
To check if there is a hole at index "2" in "arr" whose length is 5
โฅ !(2 in arr)
โ How to create a hole?
There are at least 4 ways.
โฌ Omitting values in array literals
โฌ Assigning a value to an index > length of array
โฌ Increasing value of length property
โฌ Delete an element from existing index
โ What value will you get from a hole?
undefined
โฅ let arr = [10,,20]
โฅ console.log(arr[1])
โ How holes are handled?
They are handled in many different ways. So be cautious.
โฎ Ignores holes
โฎ Ignores holes, but preserves in output
โฎ Preserves holes
โฎ Treats holes as undefined
โฎ Doesn't ignore holes
โ Introduction
โ How to specify?
โ.โ One/Two/Three/Four Values
โ.โ Percentage Value
โ.โ Horizontal and Vertical Radius
โ Other Related Properties
โ Shapes using border-radius
โ Conclusion