Introduction to Javascript

JavaScript (often abbreviated as JS) is a high level, light weight, interpreted programming language used widely in websites  and web based applications. Doesn’t matter whether big or small a web application is, you would find JavaScript embedded in it. It is a cross platform language and can be integrated in web pages.

JavaScript can be executed directly inside a browser. There is no need to install any special kind of software. Some people have confusion and think JavaScript and Java to be the same languages, although the two are different languages. JavaScript was earlier known as ‘LiveScript’ but later it got its name ‘JavaScript’ in the era when the programming language ‘Java’ was gaining popularity.

JavaScript is primarily used for client side validations and to make the website more interactive. If you want to hide an element on the click of a button and display it back on another click, you can do with the help of JavaScript.

Uses of JavaScript –

Client side validation – The most common use of JavaScript is validating input forms in websites. For example, if you want to allow a user to enter only numeric values in the text field, or if you want to validate whether a user has entered a valid format of email address, you can do that easily with JavaScript.

GUI applications – A GUI or graphical user Interface allows a user to interact with the application with the help of navigation menus or icons. JavaScript can be used to create appealing Graphical User Interfaces.

Manage CSS on HTML events – You can manage or change the CSS applied on various HTML elements with JavaScript. For example you can change the background color of an element on the click of a button.

Server side applications – Though JavaScript is a client side language, there is an open source cross platform
runtime environment called NodeJS that is used to make server side applications.

Displaying various elements like clock, calendar on the webpage.

Features of JS –

  • JavaScript is a case sensitive language. That means car and CAR are two different variables and not the same.
  • It is an interpreted language and is supported by all the major browsers.
  • It is supported by all the major operating systems including Windows, Linux and MAC OS.
  • It is a lightweight language.
  • JavaScript is a cross platform language, that means it can be embedded in any web page on a particular operating system and would work the same on any other operating system.
  • JavaScript can be embedded in web pages to make the page more interactive.
  • It is a multiparadigm language supporting procedural, object oriented and functional programming.
  • Like CSS it can be implemented inline, internally or externally. This means, you can implement JavaScript inside an HTML tag(Inline JS), as a whole part within the same page (Internal JS), or you can create a separate file (External JS) and link that file to your web page.

Advantages of JavaScript

  • JavaScript is comparatively easy to learn.
  • It is used to develop rich GUI interfaces including responsive sliders, pop ups, clocks etc.
  • It can be embedded anywhere inside a web page.
  • Client side JavaScript runs within the browser, and has no interaction with the server. This is why it is relatively fast.

JavaScript can be embedded in a web page

Printing Hello World in JavaScript –

        <title>Sample Page</title>
            document.write("Hello World");


JS Hello World

JavaScript execution on a server –

Node JS is a runtime JavaScript environment that allows JavaScript to be run outside a web browser. A full fledged dynamic website can be made by node JS, as its code can be executed on a server.