Andrea Giammarchi
1 min readSep 11, 2019

--

I like to metaphorically think at arrays like buildings (stacks) when you enter at “floor zero” and you reach the first floor, the second, and so on …

Same goes for lifts: in most countries they bring you at the floor, and they have a ground floor, which is floor zero, where you enter or get out (well, you could technically “pop” from the last floor too … base jump anyone?).

There are countries where the ground floor is counted as 1, within the lift panel, but I’ve always found those confusing, as to me the first floor cannot possibly be on entrance level.

TL;DR beside the great technical explanation, I don’t understand why it’s so difficult to count indexes from zero, till the (excluded) length of a list, after all that’s how any real-world stack works: a 2 floors apartment has a ground floor and a first floor, that’s it.

--

--

Andrea Giammarchi
Andrea Giammarchi

Written by Andrea Giammarchi

Web, Mobile, IoT, and all JS things since 00's. Formerly JS engineer at @nokia, @facebook, @twitter.

No responses yet