What is JavaScript: It’s Example, Usage

JavaScript Tutorials

JavaScript is a most popular client side scripting language developed by Brendan Eich. Originally it was named as “LiveScript” but later its name is changed to JavaScript.
Let’s have a detailed explanation on what is JavaScript with example .


What is JavaScript ?

JavaScript is a lightweight, interpreted scripting language. Note that we are calling it as a scripting language because programs in JavaScript are called as a Script. It allows us to develop complex web pages with dynamic contents, user action based events, animations and most importantly, dynamic CSS. It’s completely based on ECMAScript which defines JavaScript Standards to make it interoperable on web pages across different web browsers.
JavaScript also called as js and as a result file with JavaScript code in it has a .js extension.

Difference between Java and JavaScript

Many times novice developers get confused with JavaScript and Java because of similarity in their names. But Java and JavaScript are NOT same. JavaScript is interpreted programming language where as Java is compiled language. That means Java code must be compiled before execution. JavaScript runs only on browser whereas Java applications run on Java Virtual Machine in memory.

What is JavaScript used for ?

Mainly JavaScript is used in front layer of application where direct user interaction is involved. Let’s dive into scenarios where we can use it.

  1. To add a new dynamic HTML contents on web page, update specific part of web page and to add/remove dynamic CSS
  2. Handling user events like key press, touch, tap, mouse cursor movement etc.
  3. Share data between same application through Local Storage.
  4. Requesting server side resources with input parameters with multiple methods like POST,PUT,GET etc.
  5. Above all, Adding animations to web pages.

Limitations of JavaScript

Every programming/scripting language gives array of rich features but this does not mean it can do anything. There are limitations too!

  1. File read/write operations are not permitted in JavaScript, there is a reason for this, and the reason is User Safety!
  2. Cross domain communication is not possible through JavaScript.
  3. JavaScript can not execute script in multi threading manner therefore execution can be quite slow for long scripts.

In Conclusion, most of the limitations are for the sake of security and user safety only.

Frameworks based on JavaScript

There are many popular frameworks which has JavaScript as its base language and are developed in JavaScript. From this list you can guess capabilities of JavaScript because each of these framework getting used extensively by developers:

  1. TypeScript
  2. CoffeeScript
  3. React
  4. Angular (based on TypeScript)
  5. Backbone.js
  6. Node.js
  7. Vue.js

Each of these frameworks has its own set of features and are used in different domains, but they share a common superset features from JavaScript. You can start learning typescript from What is a TypeScript ? from the same blog.

Example of JavaScript

We can write JavaScript code at three places. Lets see each example one by one.

Within Body tag

See the Pen JavaScript Example within body tag by Code Topology (@codetopology) on CodePen.

Within head tag

See the Pen JavaScript Example within head tag by Code Topology (@codetopology) on CodePen.

External .js file

See the Pen JS Example with external .js file by Code Topology (@codetopology) on CodePen.

So this is all about JavaScript Introduction,Usage and Example. Now let’s take first step towards variable declaration and data type in JavaScript here.