Web Programming TutorialsIntroduction to JavaScript Syntaxes

Introduction to JavaScript Syntaxes

JavaScript is an interpreted and dynamic computer programming language which is widely used for web applications i.e. network centric applications. It is a lightweight programming language which is interpreted at client side in web browser. JavaScript language has syntaxes which closely resemble Java language and it has object oriented capabilities as well. It is very simple to implement because of its integration capability with HTML. It is an open source language that can executed easily at cross platforms.

JavaScript was first introduced by Netscape 2.0 in the year 1995. Formerly, JavaScript was known as LiveScript which was later renamed as JavaScript by Netscape as it resembles to Java syntactically. The core language was embedded into web browsers such as Netscape 2.0, Internet Explorer, etc. to support dynamic features of JavaScript for web applications.

Client side JavaScript language

Client side JavaScript language is the form of language which is used in collaboration with HTML document where code is interpreted and executed by the web browser at client side. JavaScript enables the web application to be dynamic as it can include programs which can be executed at web browser allowing end users to interact, and generate HTML contents dynamically. Such dynamic features with the help of JavaScript help to perform basic validations such as if user has entered valid phone number, email address, etc. in the online registration form fields. Here, we call JavaScript function at form events such as ‘onSubmit’, etc. JavaScript at web browser can act on the events triggered by users explicitly or implicitly such as button click, click on link, form action, field events such as on blur, etc.

Pros and Cons of JavaScript language

  • JavaScript language minimizes the interactions with Server as it is interpreted at web browser side. Therefore, it helps to minimize web traffic, and hence less load on the server.
  • JavaScript generates the output immediately to the visitors as it does not require web page to be loaded again and again. AJAX is the web technology which works in collaboration with JavaScript to bring the data on the current web page without reloading the web page.
  • JavaScript can perform basic client side validation at form fields level.
  • It increases the user interactivity and make the static HTML website to look dynamic.
  • It helps in the creation of richer interfaces such as drag and drop of web items, sliders to show rolling pictures and videos, etc. which enhances the look and feel of the website.

JavaScript language Limitations

  • JavaScript is not a full fledged programming language like Java. It cannot be used for reading and writing of files.
  • JavaScript do not support networking and hence it can be used for building networking applications.
  • It lacks multiprocessor or multithreading capabilities.

Development Tools for JavaScript

JavaScript can be written on a simple notepad or text editor and it really does not require any dedicated development tool. Also, no JavaScript compiler is required to compile and execute the code as it is executed in the context of web browser. In order to add more colors and make JavaScript development task very simple, the following are the development tools for JavaScript.

1. Macromedia Dreamweaver MX: The tool has many prebuilt JavaScript components, easily integrates with databases, and supports new standards such as XML, XHTML, etc.
2. Microsoft FrontPage: It is developed by Microsoft and it provides number of utilities which make the JavaScript development task easy to build interactive websites.
3. Macromedia HomeSite 5: It is JavaScript editor from Macromedia which can be used to handle personal websites very efficiently.

JavaScript Syntaxes

JavaScript – Whitespace and Line Breaks

JavaScript is an interpreted language and simply ignores whitespaces, newlines, and tabs given in the program. We can use whitespaces, newlines, and tabs in the program for formatting and indentation of the program which can make our code easy to understand.

JavaScript – Semicolons

In JavaScript language, semicolons at the end of the simple statements are optional like they are mandatory in Java programming language. We can omit semicolons by simply placing each of JavaScript statements on a separate line. Coding JavaScript program with semicolons is considered as a good programming practice. Example is shown below.

<script language="javascript" type="text/javascript">
	var1 = 100; var2 = 200; document.write (var1 + var2);

JavaScript – Case Sensitivity

Like Java programming language, JavaScript language is a case sensitive programming language. It means that variables, function names, keywords, etc. should be typed with a consistent capitalization of letters. E.g., the identifier language and LANGUAGE will convey different meaning in the JavaScript language.

JavaScript – Comments

Comments in JavaScript language can be provided in both C-style and C++-style. Therefore, any text line in the JavaScript program started with // is treated as comment till end of that line which will be ignored by the JavaScript interpreter. Multiple line comment can be given between /* and */. Also, JavaScript language recognizes HTML comment opening sequence , it should be written as //–> in order it to be recognized by JavaScript.

Given below are the examples on single line and multiple lines comments in JavaScript language.

<script language="javascript" type="text/javascript">
	//This is single line comment
	/*This is



In this article, we discussed the JavaScript language concepts, its pros and cons, limitation, and basic syntaxes along with suitable examples.


Please enter your comment!
Please enter your name here

Exclusive content

- Advertisement -

Latest article


More article

- Advertisement -