dwtutorials

Online

Javascript Statement

JavaScript statements are composed of: Values, Operators, Expressions, Keywords, and Comments.This statement tells the browser to write "Hello." inside an HTML element with id="demo"

Example :-

Result

In HTML, JavaScript statements are executed by the browser.

Hello dwtutorials

Note:Most JavaScript programs contain many JavaScript statements.The statements are executed, one by one, in the same order as they are written.

JavaScript Programs

A computer program is a list of "instructions" to be "executed" by a computer.In a programming language, these programming instructions are called statements.A JavaScript program is a list of programming statements.

Semicolons(;)

Semicolons separate JavaScript statements.Add a semicolon at the end of each executable statement:

Example :-

Result

JavaScript statements are separated by semicolons.

3

Line Length and Line Breaks

For best readability, programmers often like to avoid code lines longer than 80 characters.If a JavaScript statement does not fit on one line, the best place to break it, is after an operator:

Example

Result

The best place to break a code line is after an operator or a comma.
Hello dwtutorial!

Code Blocks

JavaScript statements can be grouped together in code blocks, inside curly brackets {...}.The purpose of code blocks is to define statements to be executed together. One place you will find statements grouped together in blocks, is in JavaScript functions:

Example

Result

JavaScript Statements

JavaScript code blocks are written between { and }