Top Posts
Reliance Jio launches streaming platform JioGamesWatch
Microsoft Teams down for thousands of users
Carbon: Google programming language as a C++ successor
JavaScript MCQs II
JavaScript MCQs I
Problem Solving Approach
Terms related to Network Security
Set in C++STL
Computer network attack (CNA)
Indexing in DBMS
TECHARGE
  • HOME
  • BLOGS
  • TUTORIALS
    • ALL TUTORIALS
    • PROGRAMMING TUTORIALS
      • JAVA TUTORIALS
      • C++ TUTORIAL
      • C PROGRAMMING TUTORIALS
      • PYTHON TUTORIAL
      • KNOWLEDGE MANAGEMENT TUTORIALS
      • DATA STRUCTURE AND ALGORITHM TUTORIALS
      • PROGRAMMING EXAMPLES
        • CPP EXAMPLES
        • JAVA EXAMPLES
        • C++ GRAPHICS PROGRAM
    • PROJECTS
      • PYTHON PROJECTS
      • SWIFT PROJECT
    • PPROGRAMMING QUIZ
    • DBMS TUTORIALS
    • COMPUTER NETWORK TUTORIALS
    • COMPUTER NETWORK SECURITY TUTORIALS
    • E COMMERCE TUTORIALS 
    • AWS TUTORIAL
    • INTERNET OF THINGS
    • CHEATSHEET
  • MORE
    • JOBS AND INTERNSHIPS
    • INTERVIEW PREPARATION
    • TECH BOOK
    • TECH NEWS
    • INSTAGRAM GALLERY
    • UNIVERSITY PAPERS
    • MNC TWEETS
    • THINKECO INITIATIVES
    • WEB STORIES
    • CONTACT US
  • WRITE +
  • ABOUT US
  • HIRE US
  • BEST COURSES
JavaScript

What is JavaScript?

by anupmaurya March 6, 2022
written by anupmaurya 0 comment

JavaScript is a programming language initially designed to interact with elements of web pages. In web browsers, JavaScript consists of three main parts:

  • ECMAScript that provides the core functionality.
  • The Document Object Model (DOM), which provides interfaces for interacting with elements on web pages
  • The Browser Object Model (BOM), which provides API for interacting with web browsers.

JavaScript allows you to add interactivity to a web page. It is often used with HTML and CSS to enhance the functionality of a web page such as validating forms, creating interactive maps, and displaying animated charts.

When a web page is loaded i.e. after HTML and CSS have been downloaded, the JavaScript engine in the web browser executes the JavaScript code. The JavaScript code then modifies the HTML and CSS to dynamically update the user interface.

The JavaScript engine is a program that executes JavaScript code. In the beginning, JavaScript engines were implemented as interpreters. However, modern JavaScript engines are typically implemented as just-in-time compilers that compile JavaScript code to bytecode for improved performance.

Table of Contents

  • Client-side vs. Server-side JavaScript
  • JavaScript History
  • Overview of JavaScript

Client-side vs. Server-side JavaScript

When JavaScript is used on a web page, it is executed in the web browsers of user’s computers. In this case, JavaScript works as a client-side language.

JavaScript can run on both web browsers and servers. A popular server-side environment for JavaScript is Node.js. Unlike the client-side JavaScript, the server-side JavaScript executes on the server that allows you to access databases, file systems, etc.

JavaScript History

In 1995, JavaScript was created by a Netscape developer named Brendan Eich. First, it was called Mocha that later was renamed to LiveScript.

Netscape decided to change LiveScript to JavaScript to leverage the fame of Java which was popular at that time. The decision was made just before Netscape released its web browser product called Netscape Navigator 2. As a result, JavaScript entered its version 1.0.

Netscape released JavaScript 1.1 in Netscape Navigator 3. In the meantime, Microsoft introduced a web browser product called the Internet Explorer 3 (IE 3), that competed with Netscape. However, IE came with its JavaScript implementation called JScript. Microsoft used the name JScript to avoid possible license issues with Netscape.

As a result, two different JavaScript versions were in the market. JavaScript in Netscape Navigator and JScript in Internet Explorer. JavaScript had no standards that govern its syntax and features. And it was decided that the language must be standardized.

In 1997, JavaScript 1.1 was submitted to the European Computer Manufacturers Association (ECMA) as a proposal. Technical Committee #39 (TC39) was assigned to standardize the language to make it a general-purpose, cross-platform, and vendor-neutral scripting language. TC39 came up with ECMA-262 which was a standard defining a new scripting language named ECMAScript (often pronounced Ek-ma-script).

After that, the International Organization for Standardization and International Electrotechnical Commissions (ISO/IEC) adopted ECMAScript as a standard (ISO/IEC-16262).

Overview of JavaScript

To define a variable in JavaScript, you use var keyword. For example:

var x = 10; var y = 20;
Code language: JavaScript (javascript)

ES6 added a new way to declare a variable with the let keyword:

let x = 10; let y = 20;
Code language: JavaScript (javascript)

To declare a function, you use the function keyword. The following example defines a function that calculates the sum of two arguments:

function add( a, b ) { return a + b; }
Code language: JavaScript (javascript)

To call the add() function, you use the following syntax:

let result = add(x, y);
Code language: JavaScript (javascript)

To log the result into the console window of the web browser, you use the console.log() :

console.log(result);
Code language: JavaScript (javascript)

Now, you should see 30 in the console window.

JavaScript provides you with condition statements such as if-else and switch statements. For example:

let a = 20, b = 30; function divide(a, b) { if(b == 0) { throw new Exception('Division by zero'); } return a / b; }
Code language: JavaScript (javascript)

In the divide() function, we checked whether the de-numerator (b) is zero. If yes, we threw an exception. Otherwise, we returned the result of a / b.

To declare an array, you use the following syntax:

let items = [];
Code language: JavaScript (javascript)

To declare an array with some initial elements, you specify the elements in the square brackets:

let items = [1, 2, 3];
Code language: JavaScript (javascript)

You can access the number of elements in the items array through its length property:

console.log(items.length); // 3
Code language: JavaScript (javascript)

To iterate over the elements of the items array, you use the for loop statement as follows:

for(let i = 0; i < items.length; i++) { console.log(items[i]); }
Code language: JavaScript (javascript)

Or use the for...of loop in ES6:

for(let item of items) { console.log(item); }
Code language: JavaScript (javascript)

To declare a “class” in JavaScript, you use the function keyword:

function Person(firstName, lastName ){ this.firstName = firstName; this.lastName = lastName; }
Code language: JavaScript (javascript)

By convention, a class name should be a noun in a UpperCamelCase, with the first letter of every word capitalized.

The following example declares a method of the Person “class”:

Person.prototype.getFullName = function(){ return this.firstName + ' ' + this.lastName; }
Code language: JavaScript (javascript)

To create an instance of the Person “class”, you use the new keyword:

let john = new Person('John','Doe');
Code language: JavaScript (javascript)

To call the method of the class you can use the ( .) operator:

let fullName = john.getFullName();

In ES6, you can use the class keyword to declare a class in JavaScript:

class Person { constructor(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } getFullName() { return this.firstName + ' ' + this.lastName; } }
Code language: JavaScript (javascript)

We have just introduced you to some features of JavaScript. You will learn each feature in detail in the subsequent tutorials.

Having fun learning JavaScript!

classClient side vs. server side javascriptjavascriptreactjsvuejs
Share 4 FacebookTwitterLinkedinRedditWhatsappTelegramEmail
anupmaurya

Hey there, My name is Anup Maurya. I was born with love with programming and works at TCS. One of best global (IT) services and consulting company as System Administrator . I also love graphics designing. It's my pleasure to have you here.

previous post
Graphic in C++ programming: Self-driving Car.
next post
What is Passwordless SSH and How to setup it?

You may also like

What is an Immediately Invoked Function Expression (IFFE)?

Recent Posts

  • Reliance Jio launches streaming platform JioGamesWatch

    August 6, 2022
  • Microsoft Teams down for thousands of users

    July 21, 2022
  • Carbon: Google programming language as a C++ successor

    July 19, 2022
  • JavaScript MCQs II

    July 11, 2022
  • JavaScript MCQs I

    July 10, 2022

Keep in touch

Facebook Twitter Linkedin Youtube Github

Categories

  • Amazon Web Services
  • C Examples
  • C Programming Tutorial
  • C# Programming Tutorials
  • C++ Graphics Program
  • C++ Programming Tutorials
  • C++ STL
  • Cheatsheet
  • Computer Fundamental And Office Automation
  • Computer Network
  • Computer Network Security
  • CPP Examples
  • Data Structure and Algorithm
  • Dbms Tutorials
  • Design
  • E-Commerce Tutorials
  • Economics
  • Educational
  • Events
  • Git and GitHub
  • Html Tutorials
  • Information System Analysis Design And Implementation
  • Internet
  • Interview Preparation
  • IoT Project
  • IoT-Internet of Things
  • Java Program Examples
  • Java Tutorial
  • JavaScript
  • JavaScript Example
  • JavaScript MCQs
  • Jobs and Internships
  • JSP
  • Knowledge Management
  • Linux
  • Matplotlib Library
  • Operating System Tutorial
  • Operator Overloading
  • Paper
  • Programming
  • Python Examples
  • Python Project
  • Python Tutorial
  • Searching Algorithm
  • Servlets
  • Sorting Algorithms
  • SQL Tutorial
  • SYSADMIN
  • Tech News
  • Technology
  • Web Development

EDUCATIONAL

  • 5+ Best Humanoid Robots In The World

  • Difference between Google Cloud Platform, AWS and Azure

  • Google Apps You Should Be Using in 2022

  • Top Sites From Where You Can Learn

  • PyScript: Python in the Browser

  • Best Fake Email Generators (Free Temporary Email Address)

  • How to Find Out Who Owns a Domain Name

  • Mobile phone brands by country of origin

  • How to start a new YouTube Channel in 2022

  • Best way to use google search you won’t believe exist

CHEATSHEET

  • HTML Cheatsheet

  • C++ Programming language Cheatsheet

  • Git and Github 2022 Cheat Sheet

  • ReactJs Cheatsheet

  • Linux Commands Cheat Sheet

  • C Programming language Cheatsheet

  • Scala Cheatsheet

PROJECTS

  • Python text to Speech

  • StopWatch using Python

  • Python Rock Paper Scissors Game

  • Currency Converter in Python

  • Alarm clock GUI application with tkinter

  • Print emojis using python without any module

  • Country Date and Time using Python

  • Covid-19 Tracker Application Using Python

  • Python | GUI Calendar using Tkinter

  • Python: Shutdown Computer with Voice

  • Python GUI Calculator using Tkinter

  • Convert an Image to ASCII art using Python

TUTORIALS

  • JAVA TUTORIAL
  • COMPUTER NETWORK
  • DBMS TUTORIAL
  • E-COMMERCE TUTORIAL
  • KNOWLEDGE MANAGEMENT
  • C++ PROGRAMMING
  • COMPUTER NETWORK SECURITY
  • AMAZON WEB SERVICES

TECH NEWS

  • Reliance Jio launches streaming platform JioGamesWatch

  • Microsoft Teams down for thousands of users

  • Carbon: Google programming language as a C++ successor

  • 5+ Best Humanoid Robots In The World

TERMS & POLICY

  • PRIVACY POLICY
  • TERMS AND CONDITIONS

COMPILERS

  • JAVA COMPILER
  • PYTHON COMPILER
  • JS COMPILER
  • C++ COMPILER
  • C COMPILER

JOBS AND INTERNSHIPS

  • TCS off-campus hiring 2022 for software engineers- 2019, 2020, & 2021 Batches

    February 27, 2022
  • Deloitte Recruitment For Any Graduates as Learning Operations Associate Analyst

    February 18, 2022
  • HP Recruitment For Tech Support Intern Position

    February 16, 2022
  • EY Hiring- PAS Global Immigration Advanced Analyst

    February 14, 2022
  • Amazon Recruitment Drive for Virtual Customer Support Associate Position

    February 12, 2022
Join Us On Telegram

@2019-21 - All Right Reserved. Designed and Developed by Techarge

TECHARGE
  • HOME
  • BLOGS
  • TUTORIALS
    • ALL TUTORIALS
    • PROGRAMMING TUTORIALS
      • JAVA TUTORIALS
      • C++ TUTORIAL
      • C PROGRAMMING TUTORIALS
      • PYTHON TUTORIAL
      • KNOWLEDGE MANAGEMENT TUTORIALS
      • DATA STRUCTURE AND ALGORITHM TUTORIALS
      • PROGRAMMING EXAMPLES
        • CPP EXAMPLES
        • JAVA EXAMPLES
        • C++ GRAPHICS PROGRAM
    • PROJECTS
      • PYTHON PROJECTS
      • SWIFT PROJECT
    • PPROGRAMMING QUIZ
    • DBMS TUTORIALS
    • COMPUTER NETWORK TUTORIALS
    • COMPUTER NETWORK SECURITY TUTORIALS
    • E COMMERCE TUTORIALS 
    • AWS TUTORIAL
    • INTERNET OF THINGS
    • CHEATSHEET
  • MORE
    • JOBS AND INTERNSHIPS
    • INTERVIEW PREPARATION
    • TECH BOOK
    • TECH NEWS
    • INSTAGRAM GALLERY
    • UNIVERSITY PAPERS
    • MNC TWEETS
    • THINKECO INITIATIVES
    • WEB STORIES
    • CONTACT US
  • WRITE +
  • ABOUT US
  • HIRE US
  • BEST COURSES