Look into Editor's Note before editing this page.

To test your JavaScript Output in Display, Keep  window opened beside this window and test your results. To get a knack in using Javascript I prefer


JavaScript is the programming language of the Web. All modern HTML pages are using JavaScript. JavaScript is easy to learn. Before we do start Javascript let's get introduced with it.

What is Javascript?

Javascript is programming language created by Brendan Eich for a company called Netscape. It quickly became very popular as it allowed web developers to manipulate the browser and its contents in ways that was not possible with ordinary HTML or Cascading Style Sheets. By using Javascript in your web pages, you can gain more control of how the page looks and behaves: document elements can be inspected, form elements validated before the contents are sent, browser details checked, cookies set, dates and times can be added to the page, even simple games can be added to a web page - all with a scripting language.

The learning curve for scripting is a lot steeper than HTML and Style Sheets. But you can learn the basics, and use scripts on your own pages, without it causing you too much trouble. The scripting language covered in these pages is meant to get you started on the subject, and is not intended as an in-depth study.

What can we use Javascript for?

  • make websites respond to user interaction

  • build apps and games (e.g. blackjack)
  • access information on the Internet (e.g. find out the top trending words on Twitter by topic)
  • organize and present data (e.g. automate spreadsheet work; data visualization)

Getting Started

Discover the length

To discover the length of a word(number of characters) write the word within quotes. Then write a full stop and the word ‘length’ like this:

 "your word".length


Say I use the word “Birthday Cake”, I will type in

“Birthday Cake”.length
The result will: 13

Now a question might arise inside your head: Why 13? It should have been 12! But you should note that spacing is also counted as a character.

Comment Statement

The // sign is for comments. A comment is a line of text that JavaScript won't try to run as code. It's just for humans to read.

 Comments make your program easier to understand. When you look back at your code or others want to collaborate with you, they can read your comments and easily figure out what your code does.

There are two types of comment statements:

  • Single line: //</li></li></li></li></li>
  • Multi line: /* ____________ */  (The long underscore between the asterisks is the comment given by user)</li>

    As written in name, Single line comment statements are only applicable in one line. But Multi line is applicable as much as the user likes. While programming programmers usually give introduction in Multi line Comment Statements.

    On the Text editor type in your name and find out its length. Also try to add in a comment statement. You can tweak a little bit and try this:

    ​"Any word".length //Hello baby
    //Stupid SHemurr

    Doing Math

    You can do any arithmetic operation in javascript. To prove it, I suggest you type in arithmetic operation in the text editor or console.

    Statement Terminator

      • sign represents a statement terminator. It is used to distinguish between two statements.

    Suppose I write: "computer".length "stupido".length

    I will get a Syntax error . The computer takes them as one statement and gets confused. That's why we need a statement terminator(;).



    Note: Always remember to add in a semi colon after completetion of one statement.

    Glitch: If you type in  "computer".length "stupido".length into the Text editor (Left side one) it will show an error(as obvious) but if you insert "stupido".length on next line, the editor will automatically insert semi colon after them(though it will not be displayed to you) and on execution it will not show an error.


    Cosnole.log() is a print statement for console. Anything that you type in the parenthesis will be calculated and then "printed" on the console. If you insert string, it will print the characters in the string. If you insert an arithmetic operation it will print the calculation's result in console.


        •  The console usually displays the final result of a program or the end statement's result. But if we want to display(or print) some result that comes in between the run time of program, we use console.log() statement.
        • The console.log() can only accept one statement.

    </li> </li>