News for hackers. Stuff that matters.
Re:Using const/let instead of var can make JavaScript code r... by pantelisk on Wednesday October 21, 2020 @04:21AM (#24845816)
It would blow your mind if you saw how much slower querySelector is compared to old school getElementByid, getElementsByClassName etc.

We tend to think that newer is better and faster, but it's also wise to think that old apis had to be fast on old hardware. Hardware that is not the target of new APIs.

Re:Using const/let instead of var can make JavaScript code r... by brundolf on Wednesday October 21, 2020 @10:34AM (#24848259)
That wouldn't blow my mind, and it's also a wildly different question. The OP is about a core language feature performing differently on two browsers. querySelector is fundamentally a higher-level API across all browsers.

Also, block-scoping is a language feature that's fundamental to virtually every other modern language out there. This isn't some high-falutin' new API. This is basic.

Re:Using const/let instead of var can make JavaScript code r... by minitech on Wednesday October 21, 2020 @07:46AM (#24846838)
> how much slower querySelector is compared to old school getElementByid, getElementsByClassName

IE 8 got querySelector before IE 9 got getElementsByClassName, so it’s not really an old vs. new thing, and I don’t think anyone expects querySelector to be faster than getElementById.