logo

Codeordie

Hello Learners

Wellcome to Every Developers to the creator world | make content | make new world

New products | new features | new learning | easy

Bibhabendu

JavaScript Journey | Part 1

13 February 2023

Bibhabendu

Bibhabendu

Let's have a closer look about javascript 2023

Javascript

Let's have closer look at JS

History Of JavaScript :

JavaScript was invented by Brendan Eich in 1995 while he was working at Netscape Communications Corporation. Eich was tasked with creating a scripting language for the Netscape Navigator web browser that would allow developers to create interactive web pages.

The initial version of JavaScript was called Mocha, and it was later renamed to LiveScript. However, due to a marketing agreement with Sun Microsystems, it was eventually renamed to JavaScript.

JavaScript Use cases :

JavaScript is a versatile programming language that can be used in a wide variety of contexts and applications. JavaScript is like BOSS!

Why Browser Important :

Till this point we know Who invent JavaScript And what are the application of JavaScript in various field.

But now the question is How JavaScript run ?. If you guys have some idea about how coding works (from 1st Year btech) then we often notice this term called COMPILER.

Any code that we try to run on our system example : take a C code and run. For that we need a C compiler that convert our High level code (Human readable) to machine code (machine readable) then we get the output.This is the simple job of compiler.

Then the answer of the above question "How JavaScript run" is by using

Compiler - The is Correct Let's see --

When JavaScript was first released, it was initially designed to be executed in the browser, where it was interpreted by the browser's JavaScript engine. Look at the term JavaScript engine.

A JavaScript engine is a browser program that interprets and executes JavaScript code. It converts JavaScript code into machine code that can be run by a computer's processor. The engine provides the runtime environment for JavaScript code.

How JavaScript Run :

Blog Post Image

When you write any JavaScript code and feed it to the browser or Website loading as real like example The JavaScript Engine come to
rescue and to the following steps:

When the all above steps are completed we get the optimized machine code that run on the cpu and we can get the output.

Some question may in you mind:

Question 1

We know that the Higher Level JavaScript code is converted to bytecode [High Level JS code] ---> [intermediate ByteCode] ---> [Machine code]
Don't you think that it take some bit extra time Then why ByteCode is
needed?

Ans: -- Yes It take some extra time compared to simply compiling JavaScript code to machine code.However, there are several reasons why bytecode is used in JavaScript engines:

Question 2

Can i say that JIT compiler will convert JS code to directly machine code and skip the byte code generation steps:

Ans:-- Yes, you are correct. JIT (Just-In-Time) compilers can skip the
bytecode generation step by compiling JavaScript code
directly to machine code.
JIT compilers work by analyzing the JavaScript code as it is
being compiling into machine code on the fly. This approach
can lead to faster execution times than using a bytecode
interpreter


However, not all JavaScript engines use bytecode. Some
engines, such as V8, use JIT compilation exclusively, while
others, such as SpiderMonkey, use a combination of bytecode
and JIT compilation. The choice of bytecode vs JIT compilation
depends on various factors, including performance, memory
usage, and platform compatibility.



Small step to appriciate