DONATE  
MENU
HTML
AJAX
PHP
CSS
JAVASCRIPT
MYSQL
JSON

JavaScript Tutorials

INTRODUCTION

» Introduction to JavaScript

» Practice IT Editor

» JavaScript Example

» JavaScript Placement

» JavaScript Syntax

» JavaScript Statements

» JavaScript Input

» JavaScript Output

» JavaScript Comments

» JavaScript Variables

» Variables' Scope

» JavaScript Operators

» JS Expressions & Concatenation

» JavaScript Data Type

» JavaScript Numbers

» Number Object

» JavaScript Strings

» String Object

» JavaScript Booleans

» Boolean Object

» JavaScript Functions

» JavaScript Arrays

» Array Object - Properties

» Array Object - Methods

» JavaScript Objects

» JavaScript Undefined

» JavaScript Nulls

CONDITIONAL TESTING

» If Statement

» If Else Statement

» JavaScript Ternary Operator

» Switch Statement

LOOPS

» For Loops

» While Loops

» Break & Continue

» For...In Loops

» do...while Loop

FUNCTIONS

» JavaScript Functions

» Creating Functions

» Functions' Parameters

» Functions' Arguments

» Function Invocation

» The Return Keyword

» The Arguments Object

» Callback Functions

» Arrow Functions

ARRAYS

» JavaScript Arrays

» Creating Arrays

» Accessing Arrays

» Looping Arrays

» Multi - dimensional Arrays

OBJECTS

» JavaScript Objects

» Creating Objects

» Prototype Definition

» Accessing Objects

» The this Keyword

AJAX

» Introduction to AJAX

JSON

» Introduction to JSON

JAVASCRIPT DATES

» The Date Object

» Date Methods

» Timing (SetInterval & SetTimeout)

MATH OBJECT

» Math Object

» Math Methods

HTML / JS DOM

» DOM Introduction

» Accessing HTML Elements in DOM

» Get And Change Elements' Contents & Values

» Change Styling - DOM CSS

» DOM Attributes

» JavaScript Event Listeners

» DOM Event Listeners

» JS Events

MISCELLANEOUS

» JS Strict Mode

» JavaScript Hoisting

» JavaScript let keyword

» Reserved Keywords

» JS Best Practices

» JavaScript vs ECMAScript

JAVASCRIPT EXAMPLES

» JavaScript Calculator

.. » JavaScript » Introduction » JavaScript Statements
Share Tweet WhatsApp

JavaScript Statements

A JavaScript statement is an instruction to the computer or browser to do something. Once, what was instructed to be done is finished, the statement ends. A program usually comprise of one or more statements carrying out different instructions to achieve the aim of the program.
//THE STATEMENTS FOR A PROGRAM

var x = 5; //First statement to declare and assign a value to a variable

var y = 25; //Second statement to declare and assign a value to a variable

var sum; //Third statement to declare a variable

sum = x + y; //Fourth statement to add two values and assign to a variable

alert(sum); //Fifth statement to alert the result
Above are examples of statements. Each does a particular thing and end. Just as in most programming languages, a JavaScript statement ends with a semicolon(;) but due to it not too strict nature, you may escape the semicolon and JavaScript will find where the statement ends but nevertheless, it is best to end your statements. A function is not a statement but functions contain statements that should do what they do repeatedly whenever called upon.
 function addMe(){
alert("You have been added."); //A statement inside a function
}
When you call a function, it becomes a statement to do something(call a function) and ends.
 addMe();
When you define a function on a variable, the variable and the function become a statement that should end with a semicolon since the function is being assigned to the variable just the way you assign just any other value to a variable.
var myFunc = function(){
};
SUMMARY
  1. Statements are individual instructions of a program.
  2. They do something (e.g declare a variable).
  3. A semicolon signifies the end of a statement.
  4. JavaScript functions and code blocks are not statements but they contain statements.
  5. When a function is called, it is a statement.
  6. When a function is defined on a variable, it is just like assigning a value to the variable and therefore, a statement.
Take a short quiz on JavaScript Statements.
Ask a question or tell us if JavaScript Statements is easy or not.
cent?

Join our 1,090 subscribers to receive tutorials' updates!

  We won't spam your mail box. We hate it.





StackBeginner 2021 © Joseph Omamode