JavaScript Programming Language

javascript, programmingtutorial.in

Introduction to JavaScript

JavaScript is the most popular and widely used client-side scripting language. Client-side scripting refers to scripts that run within your web browser. JavaScript is designed to add interactivity and dynamic effects to the web pages by manipulating the content returned from a web server.

JavaScript was originally developed by Brendan Eich of Netscape under the name Mocha, later LiveScript, and finally renamed to JavaScript. JavaScript was first introduced and deployed in the Netscape browser version 2.0B3 in December 1995. JavaScript is a trademark of Sun Microsystems.

Despite the name, JavaScript is basically unrelated to the Java, though JavaScript copies many Java names and naming conventions. JavaScript is an object-oriented language, and it also has some similarities in syntax to Java programming language.

JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complimentary to and integrated with Java. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform.

How does JavaScript work?

If we refer above figure, the browser sends request in the form of a file which is built with the help of HTML, CSS and an embedded JavaScript. The user requests his query and sends it to the server. The server processes the user’s request and respond back to the user via a file with embedded JavaScript. The process of reading the HTML file and identifying the elements contained in the file is referred as Parsing. When a script is encountered during parsing, the browser executes the script before continuing with further parsing.

Some scripts may define functions for handling events that are generated by user actions. For example, you might write a script to define a function for handling the events “submitting a form” or “clicking a click”.

Features of JavaScript

JavaScript is a script-based programming language that supports the development of both client and server components of Web-based applications.

On the client side, it can be used to write Web server programs that are executed by a web browser within the context of a web page.

On the server side, it can be used to write Web server programs that can process information submitted by a web browser and then update the browser’s display accordingly.

What JavaScript can do for you?

There are lot of things on your web page for which you can use JavaScript.

  • You can modify the content of a web page by adding or removing elements.
  • You can monitor mouse events like click, hover and can react to it.
  • The style and position of an element can be changed with the help of JavaScript.
  • You can perform and control transition and animation.
  • The operations based on user’s input can be performed.
  • The user’s inputs can be validated before submitting to the server.

These are not the only things which you can do with JavaScript, there are so many other things which can be done in JavaScript.

Advantages of JavaScript

Like all other computer languages, JavaScript has certain advantages which are written below:

Speed

Being client-side, JavaScript is very fast because any code functions can be run immediately instead of having to contact the server and wait for an answer.

Cross-browser support

JavaScript is the scripting language currently supported by the popular browsers like Netscape Navigator and Microsoft Internet Explorer.

Simplicity

JavaScript is relatively simple to learn and implement. For example, to write a JavaScript program you need only a text editor like Notepad.

Versatility

JavaScript plays nicely with other languages and can be used in a huge variety of applications. Unlike PHP or SSI scripts, JavaScript can be inserted into any HTML and CSS built web page regardless of the file extension. JavaScript can also be used inside scripts written in other languages such as PERL and PHP.

Manipulating HTML Pages 

JavaScript helps in manipulating HTML page on the fly. This helps in adding and deleting any HTML tag very easily using JavaScript and modify your HTML to change its look and feel based on different devices and requirements.

Client-side validation

This is really important to verify any user input before submitting it to the server and JavaScript plays an important role in validating those inputs at front-end itself.