While indexed arrays are more or less built on the idea of order, associative arrays are not. Javascript will generally maintain the same order in which the key, value combinations were added to the object. But don't count on it. In most languages, no particular order is guaranteed. So it's best not to depend on that here either.

You use the for in syntax to loop over an associative array:

In my opinion, this is the best solution. There's really no need to write if (students[s]) === true It's implied and it the extra code just creates an opportunity for problems.