The text says that this code "sticks the value at the end of the array", but note that this overwrites the last item already in the array (or if the array is empty it creates a property with a key of "-1").
This isn't relevant to the abstraction concept being discussed, but still it feels like an odd thing to do, so it's distracting.
comments[comments.length - 1] = txt;
The text says that this code "sticks the value at the end of the array", but note that this overwrites the last item already in the array (or if the array is empty it creates a property with a key of "-1").
This isn't relevant to the abstraction concept being discussed, but still it feels like an odd thing to do, so it's distracting.