Before we start what is inline caching, we need to know why do we need inline caching. Yeah we need caching to speed up the things, we all know that. Okay, so next part is how inline caching came into play? Inline caching history dates as long back as Google V8 engine.
Crankshaft is where the speed really comes from.
Now we move on to our main topic i.e Inline Caching. For Inline Caching let’s take a look at a code snippet.
Let’s analyze what the above code does. We create a function that takes an argument and return template string. Next, we create a userName object with keys — firstName and lastName. Now, we call function printUserName with argument of userName object several times.
printUserName(userName) = “Hello John Doe”
This is called or better known as Inline Caching. So, the gist of this whole inline caching is to write better and efficient codes knowing how the code will be processed by the engine or compiler. We should write codes that provides the intention to the machines on what we wish to do.