Skip to content
Related Articles
Open in App
Not now

Related Articles

JavaScript Statements

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 19 Dec, 2022
Improve Article
Save Article

The programming instructions written in a program in a programming language are known as statements. The order of execution of Statements is the same as they are written.

1. Semicolons:

  • Semicolons separate JavaScript statements.
  • A semicolon marks the end of a statement in javascript. 



<p id="geek"></p>
    var a, b, c;
    a = 2;
    b = 3;
    c = a + b;
              .innerHTML =
              "The value of c is " + c + ".";

  • Output:


  • Multiple statements on one line are allowed if they are separated with a semicolon.

2. Code Blocks: JavaScript statements can be grouped together inside curly brackets. Such groups are known as code blocks. The purpose of grouping is to define statements to be executed together. 

Example: JavaScript function 


<button type="button"
    Click Me!
<p id="geek1"></p>
<p id="geek2"></p>
    function myFunction() {
                  .innerHTML = "Hello";
                  .innerHTML ="How are you?";



3. White Space:

  • Javascript ignores multiple white spaces.

4. Line Length and Line Breaks: Javascript code preferred line length by most programmers is up to 80 characters. The best place to break a code line in Javascript, if it doesn’t fit, is after an operator


document.getElementById("geek1").innerHTML =
"Hello Geek!";

5. Keywords: Keywords are reserved words and cannot be used as variable name. A Javascript keyword tells about what kind of operation it will perform. 

Some commonly used keywords are:

  • break and continue: break keyword is used to terminate a loop and continue is used to skip a particular iteration in a loop and move to next iteration.
  • do…. while: In this the statements written within do block are executed till the condition in while is true.
  • for: It helps in executing a block of statements till the condition is true.
  • function: This keyword is used to declare a function.
  • return: This keyword is used to exit a function.
  • switch: This helps in executing a block of codes depending on different cases.
  • var, let  and const : These keywords are used to declare a variable in js. 

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!