Replacing a for-in loop by an index loop on an array, to avoid enumerating inherited properties