When the user visits a webpage on their browser (for e.g. Google) what they are doing is connecting to the Google servers and asking them for the Google homepage. This is called as making a request. The Google server then validates this request and returns the requested file (the Google homepage in our case). This is called a response.
In this phase the JS Engine reads the code, understands the code (i.e. what are the variables, what are the functions etc.) and performs some pre execution steps (like removing unwanted whitespaces, moving function defintions etc.)
In this phase, the parsed code is converted to machine code (i.e. a format understandable by the browser or the host machine). Conversion to machine code happens on-the-fly which means that the code conversion happens at source line by line.
In this phase, the machine code is then executed line by line and the results can be seen on the website or the host machine.
Note: In dynamic programming languages, the written code is directly converted to executable without going through the intermediate phase. Therefore, there is no need to compile the code first. The entire compilation and execution process happens together at runtime.
Weakly Typed means that the type of the data can change at runtime and datatypes are assumed automatically. This means that we do not have to specify the type of data a variable will hold. Whatever type of value is assigned to a variable, becomes the type. For e.g. a variable can hold numbers at one point (Number type) and later on that variable may hold string (String type)
If you liked this article and want to stay updated with more such articles, support me by following me on DEV and Twitter
I write about web development, AI, cloud, entrepreneurship, technology and anything else that excites me!