> eg. declare variable up front, not within loops
I have trouble believing modern JS engines wouldn’t optimize this to the same thing.
I have trouble believing modern JS engines wouldn’t optimize this to the same thing.
But it's really easy for escape analysis to fail, it has to be conservative. So you can end up heap allocating a temporary object every loop iteration quite easily.