Comment Comment by striking Sorry to nitpick, but indexOf is a bad idea. Using it is up to 1700x slower (worst case) than using object indices[1]. It's probably an O(n) operation, where indexing an Object is nearly always O(1).1: https://jsperf.com/indexof-vs-object-lookup/4 parent striking 10 years ago
1: https://jsperf.com/indexof-vs-object-lookup/4