DEV Community

0 seconds of 5 minutes, 21 secondsVolume 90%
Press shift question mark to access a list of keyboard shortcuts
00:00
00:00
05:21
 
Lakshya Thakur
Lakshya Thakur

Posted on

4

JavaScript Engine optimization during closure

TIL that Javascript engines optimize out unused variables available in outer lexical environment if they aren't used inside nested functions.

Earlier I used to think this is the default Spec behaviour but it's rather an optimization 💡.

In this video, we see how exactly Firefox confirms that for us !!

Top comments (2)

Collapse
 
varche profile image
var-che

People really underestimate the power of JS engines, and what you pinpointed in this video is just a spec in a sea of optimizations within those engines. They all utilize cutting edge of optimization techniques, and this example with closures is not new.
Anyway, good video.

Collapse
 
harshilparmar profile image
Harshil Parmar

Thanks for sharing 🙌

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay