And what some of the optimizations are that it performs
1- Compiler optimization
2- Garbage collection
3- Hot code management
5- Other runtime aspects of the program
Optimizations made by JS engine
Optimizations using Object shape
Optimizations on Arrays
Arrays also follow the same rule. Arrays are tagged as it consists of only integers, doubles, objects, etc. Whenever we use map, find etc on the arrays, it first checks the tag and generates the optimized code based on that.
In the above example, when we are trying to get the value of ‘x’, the unoptimized code will allot a new variable, assign a value of x, calculate the offset and then return the value. But if the compiler knows that this function is getting called with the same type of parameters, again and again, it will just check the shape of the parameter passed and will return the recalculated offset.
This article is inspired by conferences of Mathias Bynens