sparse array
Last updated
Was this helpful?
Last updated
Was this helpful?
โฉ โฉ โฉ โฉ sparse array
array that has "holes" in it.
"holes" are (usually) treated as .
and treat "holes" in sparse arrays differently.
๏ผtreats "holes" as .
๏ผignores "holes".
map ๏ผpreserves holes.
filter ๏ผignores holes.
an array element leaves a โholeโ in the array and does not change the arrayโs length (sparse array)
Array(3)
ๅชๆ่จญๅฎ้ฃๅ้ทๅบฆ {length: 3}
๏ผไธฆไธๆ่จญๅฎใๆดๆธ็ดขๅผใๅฑฌๆง
ๅฆๆๅ .map()
๏ผๅชๆๅพๅฐ็ฉบ้ฃๅ๏ผๅ ็บ .map()
ๆไฟ็ใๆดใใ
Array(3).fill()
ๆๅกซๅ
ฅ undefined
๏ผไธฆ่จญๅฎใๆดๆธ็ดขๅผใๅฑฌๆง๏ผ้ๆไฝฟ็จ .map()
ๅฐฑๆๆๅฏฆ้ๆๆใ