Javascript statement and syntax

JavaScript Statements

JavaScript programming language, these programming instructions are called statementsJavaScript program is a list of programming statements. statements are composed of Values, Operators, Expressions, Keywords, and Comments. These statements are executed one by one and in the same order as are written. The syntax is like,

for all javascript, tutorial follow this link:

document.getElementById("demo").innerHTML = "SMGPLAZA.";

JavaScript Semicolons, white space, line breaks and keywords.

  • Semicolon

Semicolon separate statement, Add a semicolon at the end of the statement or line or syntax. And also use for the multiple statements written in a one-line using a semicolon, and separate this by using semicolons. The syntax of how it’s written in this,

// For a single line statement.
var a,b,sum;

// For a multiple line statement.
var a=10; b=20 ; sum=a+b;
  • White Space

You can add white space in your script so sometimes it’s very adorable to read a program or understand easily. Js ignores multiple spaces. Syntax is like var name = “Hello”; or var name=”Hello”;

  • Line length and breaks.

The programmer has to avoid code lines longer than 80 words/characters. If the statement doesn’t fit in a one-line then it’s better to break the line after the operation.

  • Keywords.

Js Statement starts with a keyword to identify the action of it. many types of keyword below give this with the description of it,

breakTerminates a switch or a loop
continueJumps out of a loop and starts at the top
varDeclares a variable
do … whileExecutes a block of statements, and repeats the block, while a condition is true
forMarks a block of statements to be executed, as long as a condition is true
functionDeclares a function
if … elseMarks a block of statements to be executed, depending on a condition
returnExits a function
switchMarks a block of statements to be executed, depending on different cases
try … catchImplements error handling to a block of statements

JavaScript Syntax.

  • Variable

variables are used to store data, var keyword to use declare a variable. In this equal sign is used to assign a value for a variable like var a=20;

  • Comment

Single line comment starts with the // symbol, And in JavaScript, you can ignore to end this comment. For multiple line comment starts with /* and end with */ so basically it’s like /* …………………. */, usually when to write a basic brief of one or multiple lines or paragraph you can use it.

  • Identifier

A variable must be identified with unique names, and these unique names are called an identifier. for this it’s ruled to define an identifier, 1. names can be in the letter, digit, underscore, and dollar sign. 2.names must start with a letter, and also start with the underscore and $. 3. Names are case sensitive, so reserved words not be used as names.

  • Data type

Variable can hold as a number and a text value like “Hello”. Text values are called a string. strings are written inside double and single quotes. Numbers are not written in quotes. var x=20; var name=”hello”; var name=’hello’; var _name=”hello”;

  • Operators
  1. Arithmetic operator:- It’s used to perform on a number.

2. Assignment operator:-

OperatorExampleSame As
=x = yx = y
+=x += yx = x + y
-=x -= yx = x – y
*=x *= yx = x * y
/=x /= yx = x / y
%=x %= yx = x % y
**=x **= yx = x ** y

3. comparison operator:-

==equal to
===equal value
!=not equal
!==not equal value
>greater than
<less than
>=greater than or equal to
<=less than or equal to
?ternary operator

4. logical operator:-

&&logical and
||logical or
!logical not

5. Type operator:-

typeofReturns the type of a variable
instanceofReturns true if an object is an object type

6. Bitwise Operators:-

<<Zero fill left shift
>> right shift
>>>Zero fill right shift

Also visit this articles :-

If you have any doubts any suggestions or any query DM us one below Social media handles.

Our Social Media Handles:-

Instagram Handle :-

Twitter Handle :-

Thank you so much. You have to follow us using your mail id and also follow us on social media for more updates.