Introduction to JavaScript...

Introduction to JavaScript...

What is JavaScript

JavaScript is a programming language used Primarily by web browsers to create a dynamic and interactive user experience. It is the flagship of web development. Most web applications in modern days use some sort of JavaScript. JavaScript has so many libraries and frameworks like ReactJS, Angular, VueJS etc. for web development and it also has very good community support. Now for the definition of JavaScript, we can say this -

  • JavaScript is a lightweight, interpreted or just-in-time compiled, object-oriented programming language with first-class functions and is best known as a scripting language for web pages. But we can also use it in non-browser environments. it is a prototype-based, multi-paradigm, single-threaded, dynamically typed language and supports object-oriented and functional programming styles. [Source - MDN]

First Class Functions - When functions in a programming language are treated like any other variables then those functions are called first-class functions. In those languages, functions can be passed as an argument to other functions and can be returned by other functions and can be assigned to a variable as a value.

History of JavaScript

The first popular web browser with a graphical user interface was Mosaic, which was released in 1993. As it was accessible for nontechnical people, it played a big role in the rapid growth of the World Wide Web (www). Then the developers of Mosaic founded the Netscape Corporation and released a more polished browser named Netscape Navigator in 1994. These days web pages could only be static and they lacked dynamic behavior and interactivity. So, to remove these limitations Netscape decided to add a scripting language to the browser and in 1995, a Netscape programmer named Brandon Eich developed a new scripting language in just 10 days. It was initially named Mocha but quickly became known as LiveScript and later JavaScript.

Although JavaScript derived its syntax from Java but apart from the syntactical similarity JavaScript has no relation with Java. At the time when JavaScript was released, Java was the most popular language. So, the name similarity between these two languages was a simple marketing decision.

What is ECMAScript

ECMA is an acronym for European Computer Manufacturer's Association. It develops standards for information technology and consumer electronics. ECMA-262 or ECMAScript is a standard general-purpose scripting language mainly used for client-side scripting developed by ECMA International. It was created to ensure the interoperability of web pages across all browsers. It is a scripting language specification on which JavaSctipt is based. We can think of ECMAScript as a subset of JavaScript. JavaScript along with other languages like ActionScript, JScript etc. all use ECMAScript as its core but several modifications in these languages make them unique.

What are JavaScript Engines

The ECMAScript tells how JavaScript should be implemented by the browser so that JavaScript runs the same in all browsers, but it does not tell how JavaScript should run inside the browsers. A JavaScript Engine is a software component that executes the JavaScript code. The first JavaScript Engines were just interpreters but in modern days they use just-in-time compilers to improve performance. Every major browser has its own JavaScript Engine, for example, V8 of Google Chrome, SpiderMonkey of Mozilla Firefox, Chakra of Microsoft Edge, JavaScriptCore for Apple's Safari browser etc.

JavaScript Engines are not limited to browsers only, Chrome's V8 engine is responsible for the execution of JavaScript code in Node.js and Deno runtime systems. Now let's talk a little bit about Node.js.

What is NodeJS

Node.js is an open-source, cross-platform JavaScript runtime environment that allows JavaScript to run outside of the browser. In 2009 American software engineer Ryan Dahl created Node.js. He combined Chrome's V8 engine, an event loop and I/O APIs and created a stand-alone JavaScript runtime system. Node.js is lightweight and efficient and perfect for data-intensive real-time applications that run across distributed devices. Node.js also provides a rich library of various JavaScript modules that simplifies the development of web applications.