New Tutorials:   TKINTER    KOTLIN    JAVASCRIPT    SASS/SCSS    PL/SQL
See the Tutorial List

Introduction to JavaScript

JavaScript is a client-side, object-based scripting language that is used to handle and validate client-side data. JavaScript is also used for making the user interface of the web pages more dynamic making it responsive to events like the movement of the mouse, mouse click on a certain HTML element, a button click, etc, using which we can improve the user experience.

JavaScript is a lightweight scripting language based on ECMAScript standards. It executes on the browser and therefore reduces the load on the server. JavaScript can also be used to create cross-platform applications or SaaS applications or to create a Back-end server-side application by using NodeJS.

It is an interpreted language which means the script written inside Javascript is processed line by line and is not compiled before processing. These Scripts are interpreted by JavaScript interpreter which is a built-in component of the Web browser. Although this is changing lately, with the introduction of V8 engine in Chrome and NodeJS, now just-in-time compilation is also used for JavaScript.

JavaScript is Platform Independent, which means you need to write the script once and can run it on any platform or browser without affecting the output of the Script.

JavaScript, formerly known as LiveScript, has been developed by Netscape and Sun Microsystems. It is also known as ECMAScript as it was standardized by European Computer Manufacturer's Association(ECMA). The most recent upgrades were the ECMAScript6, ES7, ES8, ES9, ES10 and the most recent ECMAScript2020 which came at the beginning of this year. Although you should update yourself with all the new features ECMAScript6 was the most significant change and we will be covering more about it towards the end of this tutorial series.

Browsers use their own JavaScript Engines to execute the JavaScript code. Some commonly used browsers are listed below:

  • Chrome uses a V8 engine.

  • Firefox uses the SpiderMonkey engine.

  • Microsoft Edge uses the ChakraCore engine.

  • Safari uses the SquirrelFish engine.

Web Development Roadmap:

If you are a beginner, we advise you to learn HTML and learn CSS first and then it will be easier for you to understand JavaScript. In web development, HTML is the basic building block that can be used to develop basic webpages, which can have hyperlinks, images, forms, etc. Then comes CSS which is used for styling the various HTML elements to make them look good. CSS is a standard for providing styling to your HTML elements and these days no website is created without it.

Learn SASS/SCSS which is a new language that enables us to write dynamic styling rules just like any other programming language which can be converted to CSS code and can then be used in an HTML page.

Then comes JavaScript, which as we mentioned is a scripting language used for handling and validating client-side data, making webpages dynamic based on events, enabling features like cookies, local storage, etc and a lot more.

Let's see some features of JavaScript.

JavaScript Features

Following are some of the most useful features of JavaScript:

  • Light Weight

  • Dynamically Typed

  • Object-Based

  • Functional

  • Platform Independent

  • Prototype-based

  • Interpreted

  • Asynchronous

Let's see what all these features mean:

Light Weight: JavaScript is a lightweight scripting language because it is made for data handling at the browser level only. Since it is not a general-purpose language so it has a limited set of libraries.

Dynamic Typed: JavaScript supports dynamic typing which means types of the variable are defined based on the stored value. For example, if you declare a variable x then you can store either a string or a Number type value. This is known as dynamic typing.

Object-Based Language: JavaScipt is an object-based scripting language that provides built-in objects like String, Math, Date, etc.

Functional Style: This implies that JavaScript uses a functional approach, even objects are created from the constructor functions and each constructor function represents a unique object-type.

Platform Independent: This implies that JavaScript is platform-independent or we can say it is portable; which simply means that you can simply write the script once and run it anywhere and anytime. In general, you can write your JavaScript applications and run them on any platform or any browser without affecting the output of the Script.

Prototype-based: JavaScript is a prototype-based scripting Language. This means javascript uses prototypes instead of classes. In JavaScript, each constructor function is associated with a prototype object. This is a bit confusing concept but consider it this way, like we have class in Java which is like a blueprint and then we create objects for the class(Understand the concept of Class, Objects and OOP), in JavaScript, we define Object prototype which is used to create other objects. Don't worry if you don't understand this now, you will understand this as you will progress with the tutorial.

Interpreted: JavaScript is an interpreted language which means the script written inside javascript is processed line by line and is not compiled before execution(although this is changing slowly, with different JavaScript engines being created by different browsers). These scripts are interpreted by JavaScript interpreter which is a built-in component of the Web browser.

Asynchronous: JavaScript can be used to do complex processing asynchronously which means that the whole page will not have to wait for the JavaScript processing, and once the script processing completes we can easily modify the HTML code to show or hide data. Also, we can use JavaScript to send async HTTP requests to the server for server-side processing too.

Advantages of JavaScript

JavaScript has various advantages that make it very useful as a scripting language, some are listed below:

  1. JavaScript makes the webpage more interactive and dynamic.

  2. By using JavaScript you can make your webpage to give immediate feedback to the user so that they would not have to reload the page.

  3. You can use JavaScript to perform actions based on how the user interacts with your webpage using the events generated like a mouse click, form submit, button click and a lot more.

  4. JavaScript can save server traffic by validating the user inputs before even sending data to the server.

  5. JavaScript can be used to store client-side cookies to store data on the client-side and then read them or delete them.

  6. JavaScript can be used to make async HTTP calls to load data from the server.

Limitations of JavaScript

JavaScript has some limitations too which are listed below:

  1. Like Java and other general-purpose programming languages, JavaScript is not capable to write multi-threading or multiprocessor code.

  2. Core JavaScript can't be used for developing networking applications, although there are some frameworks available like NodeJS which can be used for this.

  3. JavaScript can only be used on the client-side i.e. for frontend development.

  4. JavaScript is processed in the browser, and if someone disables JavaScript in their browser, no JavaScript code will be processed. So if you are validating form values using JavaScript and if any user of your website switches JavaScript off in his/her browser, then your form validation will stop working.

  5. JavaScript opens up a lot of doors and windows for security researchers and hackers to play around with a webpage.

Conclusion:

So with this, now you have a brief introduction about JavaScript. In the upcoming tutorials we will cover all the basics of JavaScript and then we will move on to the more complex parts of it.