.

Syntax in JavaScript Assignment Help

Syntax in JavaScript

Javascript program can be written with in HTML starting tag < HTML > and End tag < /HTML >.

Javascript executable statements start with in < script> < /script>. The tag < script> indicates the browser the following statement to be interpreted.

Protocol for Javascript

{`





		`}

Syntax in JavaScript Assignment Help Through Online Tutoring and Guided Sessions at MyAssignmentHelp


Script tag has two attributes

  • Language
  • Type

Language –It specifies what scripting language is to be used. Valid values are vbscript and javascript etc., For Javascript the value should be javascript.

Type − This attribute value set to "text/javascript".

2.1 Your First JavaScript Code

The following code is an example for Javascript.

Javascript syntax img1

Scripting language embedded with in < script> < /script> tags. The statement document.write to display the result in output console.

2.2 Whitespace and Line Breaks

JavaScript does not process whitespace and line breaks. The following program illustrate the above.

Javascript syntax img2

2.3 Semicolons are Optional

Each statement in Javascript ends with (;). This is optional. The following example shows how code executes without ending operator(;).

Javascript syntax img3

2.4 Case sensitivity

It is case sensitive language. Upper case letters are different from lower case letters.

Example:

A=10;

a=10;

Here the two variables ‘A’ is not same as ‘a’.

2.5 Comments in JavaScript

Javascript supports the following commenting statements:

{`
•	//
•	/*………*/
•	< !--.statement //-- >
// -It is used to single line as comment line
/*….*/-More than one statement as comment line
< !--   - It is used to make single line as comment line.
The closing tag is //-- >
`}

Demo:

Javascript syntax img4
.