Introduction to JavaScript

JavaScript is a very powerful and popular scripting language. It is very simple to learn. Its short form is JS. The filename extension for javascript is ‘.js’. JavaScript is an event-driven, functional, object-oriented, multi-paradigm language. JavaScript and Java are both different languages. Do not get confused or misunderstand between them. They have different syntax, semantic, and uses.

Usage:

It is used in web pages, desktop and server programs, some databases, and non-web programs. Node.js, MongoDB, CouchDB, Adobe Acrobat uses javascript. It is also used for game and mobile application development.

History:

JavaScript was designed by Brendan Eich in 1995. Its official name is ECMAScript.

Support:

All modern browsers support javascript language. So, when a user visits your page you don’t have to worry about whether it is Internet Explorer, Chrome, Firefox, or any other browser. JavaScript can be run on any operating system like Windows, Linux, or Mac.

Tools:

  1. Editor: You need a text editor for writing your code. You can choose any editor like notepad++, Visual Studio Code, Atom, Sublime Text, WebStorm or any other.
  2. Web Browser: As javascript is a scripting language, it does not run on its own. It is run on a web browser when the HTML page is requested. So you need a web browser for running javascript. You can choose any web browser like Firefox, Google Chrome, Microsoft Edge, Opera, Internet Explorer or any other.

Hello World program in JavaScript:

JavaScript is placed between <script> and </script> tags. In following example also it is placed between <script> tags.

Step 1: Create an HTML file and paste the following code.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Hello World</title>
    <script type="text/javascript">
      alert("Hello World from Javascript!");
    </script>
  </head>
  <body>
  </body>
</html>

Step 2:

Open the file in any browser and you will get an alert message.

hello world in javascript

**Note:

You can also add javascript files externally by giving their source address.

Example: <script src=”./external.js”></script>

Other scripting languages:

There are other scripting languages like CoffeeScript, TypeScript, Dart, etc. They have their own different syntax. They all get auto-converted into javascript code for running.

Additional Links:

If you want to learn how to use variables and expressions in javascript, click the following link.

Variables and Expressions in JavaScript

Strings in JavaScript

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments