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.
- To add a new dynamic HTML contents on web page, update specific part of web page and to add/remove dynamic CSS
- Handling user events like key press, touch, tap, mouse cursor movement etc.
- Share data between same application through Local Storage.
- Requesting server side resources with input parameters with multiple methods like POST,PUT,GET etc.
- 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!
- File read/write operations are not permitted in JavaScript, there is a reason for this, and the reason is User Safety!
- Cross domain communication is not possible through JavaScript.
- 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:
- TypeScript
- CoffeeScript
- React
- Angular (based on TypeScript)
- Backbone.js
- Node.js
- 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.