Javascript Tutorial
Javascript Tutorial Introduction to Javascript JavaScript Code Editors & IDE JavaScript Hello World Example Javascript Syntax and Rules syntax_rules javascript_identifiers JavaScript Keywords & Reserved Words javascript_variables JavaScript Const JavaScript let vs var vs const Data Types in JavaScript JavaScript String Template Literals & String interpolation in JavaScript Tagged Templates in JavaScript String to Number in JavaScript Number Data Type in JavaScript NaN in JavaScript JavaScript Number Min & Max & Safe Values JavaScript EPSILON & Floating point precision Infinity in JavaScript JavaScript Bigint BigInt Vs Number in JavaScript Boolean Data Type in JavaScript Undefined in JavaScript Null in JavaScript Null vs Undefined in JavaScript JavaScript Operators Arithmetic Operators in JavaScript Unary plus & minus operators in JavaScript Increment & Decrement Operators in JavaScript Comparison or Relational operators in JavaScript Strict Equality (==) Loose Equality (===) in JavaScript Ternary Conditional Operator in JavaScript Logical Operators in JavaScript Bitwise Operators in JavaScript Assignment Operators in JavaScript Nullish Coalescing Operator in JavaScript Comma Operator in JavaScript Typeof JavaScript Operator Precedence in JavaScript JavaScript if, else & nested if statement Switch Statement in JavaScript While & Do While Loops in JavaScript For Loop in JavaScript Break statement in JavaScript Continue Statement in JavaScript Arrays in JavaScript Array Constructor in Javascript Sparse Array Vs Dense Array in JavaScript How to merge Arrays in JavaScript Array Methods in JavaScript Functions in JavaScript Function Parameters & Arguments in JavaScript JavaScript Default Parameters Pass by Value and Pass by Reference in Javascript Function Expression in Javascript Nested Functions in JavaScript Immediately-invoked Function Expressions (IIFE) JavaScript Callback Functions Arrow Functions in JavaScript Arguments Object In JavaScript Rest Parameters in JavaScript Objects in Javascript Create Objects in JavaScript JavaScript Object Properties Computed Property Names in JavaScript Object Literal in JavaScript Constructor Function & New Operator in JavaScript Delete Operator in JavaScript hasOwnProperty in JavaScript Using Getters and Setters in Javascript DefineProperty in JavaScript JavaScript Property Descriptors Enumerable, Writable & Configurable Object Destructuring in JavaScript Variable Scope in JavaScript Hoisting in JavaScript Lexical Scope & Closures in JavaScript This in JavaScript Global Object, Window & Globalthis in JavaScript Call function in Javascript Prototype In Javascript Prototype Inheritance in JavaScript Instanceof Operator in JavaScript Spread Operator in JavaScript

Introduction to Java Script

In this article, we’d like to introduce you to JavaScript. It is one of the most famous & commonly used languages. Today Javascript powers millions of web pages and makes them interactive. It helps validate forms, run business logic on the client, create cookies, animate, and more. It runs on all devices, including Windows, Linux, Mac, Android, iOS, etc., and is supported by all browsers.

What is Javascript

Javascript is the scripting language, we use to make web pages interactive. It is written in plain text on the HTML page and runs in the browser. Modern JavaScript evolved so much that, it can run on the server side today. We use it along with HTML & CSS and powers the entire web.

History

.

Brendan Eich of Netscape developed JavaScript for Netscape in 1995. It started as Mocha, then became LiveScript, and later JavaScript.

Java was a very popular language at that time. Hence the marketing folks at Netscape decided to name it JavaScript to encash Java’s popularity. They also designed it so that its syntax looks similar to that of Java.

Microsoft included support for JavaScript (named JScript) from Internet Explorer 3.0. It also had its scripting language VBScript. Other browsers also incorporated JavaScript, while VBScript remained only with Internet Explorer. This eventually led to the demise of VBScript.

The browser vendors started to come out with their implementation of JavaScript. Since there was no standard, each browser was free to implement. Hence the need for standardizing the syntax & rules of JavaScript.

In 1997. Netscape presented JavaScript to ECMA International, which standardized the specifications of the JavaScript under the nameECMAScript specifications (pronounced as “ek-ma-script”). The browsers now implement Javascript using ECMAScript specifications, which is why the JavaScript programs behave similarly across all browsers.

How it is Used

We use JavaScript to create and manage dynamic web pages. It works side by side with HTML & CSS.

The HTML provides the content & structure of the web pages. You can create content using headings, paragraphs, tables & images, etc.

The CSS controls how the Web looks like. You can set color, font styles, backgrounds, borders, etc.

JavaScript makes it dynamic. Using JavaScript, you can respond to user events, Take input from the user, Validate those inputs, run business logic, read and send data to the servers, etc. It can also alter the content & look by manipulating the HTML & CSS on the fly.

Creating a JavaScript Program

There are two ways you can include JavaScript. You can embed it directly inside an HTML Page or Include it as a separate file.

The following is an example shows how you can write JavaScript directly in an HTML file

                            
<!DOCTYPE html>
<html lang="en">
<head>
    <script>
    <document.write("Hello World from Javascript")
    </script>
</head>
<body>
    <p>The Content from the HTML<p>
</body>
</html>
                            
                            
                        

Copy the above code to any text file and name it as index.html. Open it in any browser and you will see the following in your browser.

Hello World from Javascript
                            

Hello World from Javascript

The Content from theHTML
                                
                        

Note that we do not have to do anything to make the above code run.The browser will read the </script> tag and recognize the content as JavaScript code and executes it.

JavaScript is an interpreted language

JavaScript is an interpreted language. We cannot compile a JavaScript program into an executable. We distribute it as plain text.

To run an interpreted language, the client machines require an Interpreter. The Interpreters read the program line by line and execute each command. The Interpreted languages were once significantly slower than compiled languages.

Every browser comes with a built-in Interpreter in the form of a Javascript virtual machine

Javascript virtual machine

The JavaScript virtual machine (JVM) is the component of the browser that reads our JavaScript code, optimizes, and executes it.

The job of JVM is to Interpret the JavaScript code and run it. Each browser comes with a version of JVM. The following are some of the popular JVM

  • V8— Developed by Google for chrome.
  • Rhino — Developed by Mozilla Foundation for Firefox
  • SpiderMonkey — The first JavaScript engine, used by Netscape Navigator, and today powers Firefox
  • JavaScriptCore — Developed by Apple for Safari
  • Chakra — Developed by Microsoft and runs on Microsoft Edge
  • JerryScript — is a lightweight engine for the IoT devices

Javascript Tools & Frameworks

Many tools, Libraries & Frameworks are available, making working with Javascript easier.

A JavaScript framework is an application framework written in JavaScript. It contains tools & libraries and defines the entire application design.

The following are some of the popular JavaScript libraries & frameworks

Javascript Transpilers

A JavaScript Transpiler is a tool that reads source code written in a different programming language and produces an equivalent code in Javascript.

Learning Javascript