DEV Community

loading...
Cover image for Enough JavaScript to get you Started : #1 How It works?

Enough JavaScript to get you Started : #1 How It works?

whoadarshpandya profile image Adarsh Pandya ・2 min read

How a Program Works?

ipo.png

The Core Steps

  1. Input
  2. Process (Bussiness Logic)
  3. 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

  1. simple calculator can perform operations like addition , subtraction, multiplication and division for the sake of understanding.

  2. it should generate a output based on what operation our end user wants to perform.

  3. After generating our code should display result in appropriate manner which can be understandable to end user.

Thinking in Terms of IPO

  1. Input : in given problem we can consider 3 inputs from a user (i.e number1 , number2 and operation which user want to perform [+,-,*,/] ).

  2. Process : after taking input our code should be able to perform operation which user want code to perform in our case simple calculations.

  3. 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 ❀

Discussion (3)

pic
Editor guide
Collapse
cmlandaeta profile image
cmlandaeta

ContinΓΊa broy

Collapse
fltenwall profile image
flten

Keep doing!

Collapse
whoadarshpandya profile image
Adarsh Pandya Author

Definitely πŸ’―