JavaScript array length is weird

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
JavaScript array length is weird if we create a basic array in JavaScript we can get its length by calling the length property on the array but we can also mutate this property so we can set our array's length to let's say two and it cuts off the last item of the array which might be intended Behavior but what if we increase the length now to something like 5 it happily accepts that and now our array contains three empty items not undefined values there's just nothing there and if we try to access one of them it's just like we try to access the key that doesn't exist in the array at all but we can put a value there if we wanted to and the other empty items that still exist in their places keeping the length at five so yeah in case you didn't know
Info
Channel: Andrew Schmelyun
Views: 291,861
Rating: undefined out of 5
Keywords:
Id: f-7gUixaETw
Channel Id: undefined
Length: 0min 50sec (50 seconds)
Published: Fri Oct 14 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.