another way to make it more efficient is to define var item = items[i]; in the loop and reuse this variable