Breaking News

Understanding JavaScript Syntax.

In this article, we will learn about Understanding JavaScript Syntax. So, As you see JavaScript is written as plain text like HTML, CSS.

JavaScript Syntax


JavaScript is called interpreter language not compiler language like other languages, c, Java. Others languages need to run special programming which is called a compiler. Who takes your code convert into machine code which then can run on the operating system. We do not need to do that in JavaScript.

We simple write our code and we handover to web browser and web browser takes and interprets the code running on the machine.

<!doctype html>






<p>regular body text</p>







JavaScript is Case Sensitive!

If you are coming in-sensitive languages like visual basic, Pascal, or HTML, it is really imprinted to understand that JavaScript is case sensitive.

Does not matter.

Does not matter

<p>Regular paragraph text goes here. </P>

But here it matters.


alert (“Hello world”);

Alert (“Hello world”);

JavaScript code like the most programming language is grouped in statements, separate in instructions commands piece by piece, what do you want to do with the statement.


  • Change color of the headline.
  • Calculate age.
  • Move image.
  • Hide menu.
  •  Alert “important message”.

3 alert

alert(“Hello world”);

 multiple statements

alert (“Hello world”); alert(“Another message”);

You can type more than the statement in one line but not recommended it is too harder when you type big program. I advise you splits multiple statements into multiple lines.

5 multipel statments

Alert(“Hello world”);

Alert(“Another message”);

Type multiple statements in multiple lines.

Use one statement in one line.

Each JavaScript statement should end with the semicolon and because of this, you can put multiple statements.



<p>Regular paragraph text goes here.</p>

There is a closing tag. But if you do not use the closing tag program will work but it is not a good sign or good practice.

JavaScript will forgive some omissions.

Alert(“Hello world”);

At the end, you must give semi colon.

JavaScript is whitespace insensitive.

Alert(“Hello world”);

Alert(                 “Hello world”           );


(            “Hello world”


Alert(“ Hello                       world”);

                             But in above there is space so js considers there is space between “Hello and between world”

JavaScript Comments.

As you are writing code, you should also add comments. So, you can add your comments in JavaScript by simply typing a line with two forward slashes both together”//”.

JavaScript than ignores anything after two forward slashes and begin the again the next line, typically you add the comments above the one referring to but you can also add them at the end of statements.

You can also add JavaScript Comments on multiple lines.

By typing forward slash and asterisk everything after that is considered as comment even it has 100 lines later and till you see the asterisk and forward slash.

//this is comment

Alert(“hello”);//can go here

/*this is





Execution Order.

Like most programming languages that the default behaviours, when JavaScript runs. It starts at the first statement and move down and executes line by line.

The question is when?

As soon your browser sees your code.

Execution order.

  • Change color of the headline.
  • Calculate age.
  • Move image.
  • Hide menu.

Alert “important message”

Execution order is line by line.

In JavaScript Syntax article, we have learned the following topics.

  • Structure.
  • JavaScript is case sensitive!
  • Statements.
  • JavaScript will forgive some omissions.
  • JavaScript is whitespace insensitive.
  • JavaScript Comments.
  • Execution Order

Learn How to Make Money Online in Best and Easy ways.

Spread the love

About imran

My Name Mohammad Ramzan Bhutto. Live in District Jacobabad, Sindh, Pakistan. I have started blogging on Information Technology, my selected areas are Online Business, Digital Marketing, Make Money Online.

Check Also

Embedded Style Sheet

How to Use Embedded Style Sheet. Embedded Style Sheet or Internal style sheet is the …