How a Program Works?
The Core Steps
- Input
- Process (Bussiness Logic)
- Output
How it works?
as we can see in the image any program works majorly on 3 core steps namely Input, process and output
Example
Consider building a simple calculator , we'll divide this main problem into part of small problems to identify what is input , what are processes and what output we want our code to generate
Smaller Parts of main Problem
simple calculator can perform operations like addition , subtraction, multiplication and division for the sake of understanding.
it should generate a output based on what operation our end user wants to perform.
After generating our code should display result in appropriate manner which can be understandable to end user.
Thinking in Terms of IPO
Input : in given problem we can consider 3 inputs from a user (i.e number1 , number2 and operation which user want to perform [+,-,*,/] ).
Process : after taking input our code should be able to perform operation which user want code to perform in our case simple calculations.
Output : result generated in process will be shown to user .
How JS works behind the scenes?
After Writing the code, we need to execute it. in our case we need a browser environment (i.e chrome,firefox,safari). All of these browsers have a compilation engine built in which comes with software.
work of compilation engine or compiler is to compile the written code and convert it into machine understandable code !
Different Compilers :
👉 Chrome : V8
👉 Firefox : Spider Monkey
👉 Safari : WebKit
JavaScript is an interpreted language, not a compiled language. A program such as C++ or Java needs to be compiled before it is run. The source code is passed through a program called a compiler, which translates it into bytecode that the machine understands and can execute. In contrast, JavaScript has no compilation step. Instead, an interpreter in the browser reads over the JavaScript code, interprets each line, and runs it. More modern browsers use a technology known as Just-In-Time (JIT) compilation, which compiles JavaScript to executable bytecode just as it is about to run.
Let me know in comment section if you have any doubt or feedback. it's always worth to give time to thriving developer community :)
Keep Coding ❤
Top comments (3)
Continúa broy
Keep doing!
Definitely 💯