JavaScript Code Execution - Simplified


JavaScript executes code in two phases:
Memory Creation Phase (Variable Setup):
This is where JavaScript gets ready to work.
It sets up space in memory for things like variables and functions.
Variables are prepared but don't have values yet; they are like empty boxes.
Functions are stored in memory with all their instructions, like a recipe.
Code Execution Phase (Doing the Work):
Now, JavaScript starts doing the actual tasks in your code.
It works one step at a time, following the order of your code.
When it sees a variable, it gives it a value.
If there's a function, it runs that function like a small program.
After the function finishes, the result is saved, and the function's stuff is removed.
Think of it like making a list of what you need to do (Memory Creation Phase) and then actually doing each task one by one (Code Execution Phase). When you have a recipe (function), you follow the steps in the recipe, and when you're done, you put away the recipe and keep the dish you made.
Jai Hind, Vande Mataram 🇮🇳
Do you know how many types of hackers are there?
Sounds too complicated? Read the Simplified Versions
Read more about React & JavaScript
Follow me for more such content
Subscribe to my newsletter
Read articles from Jay Tillu directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Jay Tillu
Jay Tillu
Hello! I'm Jay Tillu, an Information Security Engineer at Simple2Call. I have expertise in security frameworks and compliance, including NIST, ISO 27001, and ISO 27701. My specialities include Vulnerability Management, Threat Analysis, and Incident Response. I have also earned certifications in Google Cybersecurity and Microsoft Azure. I’m always eager to connect and discuss cybersecurity—let's get in touch!