Arrow

JavaScript Syntax

AuthorHariom Prajapati

Pubish Date24 Jul 2022

categoryJavaScript

JavaScript syntax is a set of rule according which we can write code of JavaScript.

  • Case sensitivity

JavaScript is case sensitive, lowercase and uppercase letters are different.

 

Example -

<script>

var a=10;

console.log(a); // it produce output 10

console.log(A); // it show error because of case sensitive

</script>

 

  • White space

JavaScript ignore white space. You can use white space in your programs.

 

Example -

<script>

var a= 10; //we can use space because JS ignore white space

console.log(a); // it produce output 10

</script>

 

  • Semicolons

Semicolons terminate the statement.

It is optional.

For good programming you should use semicolons.

 

Example -

<script>

var a= 10; //semicolon used to terminate the statement to next line

console.log(a) // no need to use semicolon because no JS code written below

</script>

 

  • Comments

Comments are same like other language and the line written inside comment cannot be execute like others language.

Learn more about comment in text topic.

 

Example -

<script>

var a= 10;

// window.alert(a);

//No output because window.alert(a) inside comment

</script>