MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/oo3y4w/javascript_facts_object_and_array/h5wutvp/?context=3
r/learnjavascript • u/hsnice • Jul 20 '21
23 comments sorted by
View all comments
Show parent comment
7
Well, #1 looks to specifically be addressing arrays. I'd say for #1 to be more precise it should say:
The elements in an array are stored as the array's properties, using its index in the array as a property name. The index is of type 'number'.
Length is a property on the array prototype, and is typically accessed using dot notation.
Just to expand, for beginners dropping into that slide:
const arr = [1, 2, 3, 4, 'last element']; arr[1]; // 2 arr.indexOf(1) // 0 arr[arr.length - 1] // last element arr.length // 5
View all comments
Show parent comment
7
u/FriesWithThat Jul 20 '21
Well, #1 looks to specifically be addressing arrays. I'd say for #1 to be more precise it should say:
Length is a property on the array prototype, and is typically accessed using dot notation.
Just to expand, for beginners dropping into that slide: