Message from JavaScript talks

July 2017

— This gets invoked inside a damn medusa snake head function lol


for (let i = 0; i < arr.length; i++) {

is slower than
const arrLength = arr.length;
for (let i = 0; i < arrLength; i++) {

— Really?

— Yep

— How did you find that out?

— Because .length runs some code to calculate the length when you access it

— All I read said it was just as fast

— This is the opposite of what I thought it did

— As far as I could tell it is efficient on normal arrays

— Https://

— So I guess V8 is smart enough to optimize it nowadays

— Hm, but the dereference, is it that substantial?