What is JavaScript ?

What is JavaScript ?

  • JavaScript is a high-level, prototype-based, object-oriented, multi-paradigm, dynamic, interpreted or just-in-time compiled, single threaded, garbage-collected programming language with first-class functions and a non-blocking event loop concurrency model.

  • JavaScript has application programming interfaces (APIs) for working with text, dates, regular expressions, standard data structures, and the Document Object Model (DOM).

  • JavaScript is a scripting or programming language that allows you to implement complex features on web pages.

  • JavaScript is used for backend development, frontend development, game development and mobile development.

  • JavaScript is the "language of the web".

  • JavaScript was invented by Brendan Eich in 1995(in just 10 Days😯), and became an ECMA standard in 1997.JavaScript was first known as LiveScript, but Netscape changed its name to JavaScript, possibly because Java was then a popular programming language, later JavaScript became a hit as well.

  • JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complimentary to and integrated with Java. It is complimentary to and integrated with HTML.

  • A JavaScript engine is a software component that executes JavaScript code. JavaScript engines are typically developed by web browser. i.e., V8 is a free and open-source JavaScript engine developed for Google Chrome web browsers.

Following are the core features of JavaScript:

  • High-level language: JavaScript is a high-level programming language. Any program needs resources, such as memory, to run. For low level language like C, the programmer needs to manage the resources by programmer. For high level language like JavaScript, the engine will take care of the resources for the programmer. High-level language is closer to human language. This make JavaScript language easier to learn and use.

  • Garbage-collected: JavaScript is garbage-collected language. garbage-collection is most powerful tool that take memory management away from the programmer. The engine will automatically allocate memory when needed, and free it when it is no longer needed. Garbage collection is algorithm inside a JavaScript engine that automatically removes unused memory which not clog up the memory.

  • Interpreter or just-in-time compiled: JavaScript is an interpreted language. Coverts the source code into machine code line by line during runtime. JavaScript is also a just-in-time compiled language. The engine will compile the entire source code into machine code before executing any of it.

  • Multi-paradigm: JavaScript is a multi-paradigm language. It supports object-oriented programming, procedural programming and functional programming.

    I. Object-oriented programming: JavaScript is an object-oriented programming which means that it is based on objects. An object is a collection of related data or functionality. In JavaScript, objects can be created in three ways: object literals, constructor functions, and classes.

    II. Procedural programming: JavaScript is procedural programming which means that it is based on procedures or routines. A procedure is a set of statements that performs a task or calculates a value.

    III. Functional programming: JavaScript is functional programming which means that it is based on functions. A function is a block of code that performs a specific task. A function can be reused multiple times.

  • Prototype-based: JavaScript is prototype-based language. prototype-based means that objects inherit directly from other objects. In JavaScript, objects can inherit from other objects by defining a prototype object. example, creating array and pushing value into the array. we create an array blueprint and this is called prototype(prototype contains all the array methods) and array that we create in our code inherits from this prototype.

  • First-class functions: JavaScript is a first-class functions language. Function are treated as objects. This means that functions can be assigned to variables, passed as arguments to functions and returned from functions.

  • Dynamic language: JavaScript is a dynamic language. This means that the type of a variable is determined during runtime. In contrast, in a statically-typed language like Java, the type of a variable is determined at compile time.

  • Single-threaded: JavaScript is a single-threaded language. This means that only one set of instructions can be executed at a time. In contrast, in a multi-threaded language like Java, multiple threads can run concurrently. For long running tasks, this can be a problem as the application will become unresponsive. However, JavaScript has a concurrency model based on an event loop, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks. Event loop takes long running tasks and executes them in the background, and puts them back in the main thread once they are finished.

  • Non-blocking behavior: JavaScript is a non-blocking language. This means that the execution of code will not block other operations. For example, when making a request to an API, JavaScript will not wait for a response. Instead, it will execute the next line of code. When the response is ready, an event is fired and a callback function is executed. This is known as an event-driven architecture.

  • Open source: JavaScript is an open source language. This means that anyone can contribute to the language by creating a pull request to the JavaScript engine repository.

Web libraries and frameworks

  • jQuery: jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript. Documentation : jQuery

  • React: React is a JavaScript library created by Facebook. It is a User Interface (UI) library .It is a tool for building UI components. Documentation : React

  • Node.js: Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Documentation : Node

  • Angular: Angular is a platform for building mobile and desktop web applications. Documentation : Angular

Documentation: JavaScript