Register to get access to free programming courses with interactive exercises

Statements JavaScript fundamentals

A statement is a command given to a computer to do something. The JavaScript code is a set of statements which are usually separated by a ; symbol.

Instructions

Here is an example of some code with two statements.

console.log('Mother of Dragons.');
console.log('Dracarys!');
// => Mother of Dragons.
// => Dracarys!

Multiple statements can theoretically be placed on the same line:

console.log('Mother of Dragons.'); console.log('Drakarys!');

The output on the screen will be the same, but because the code is difficult to comprehend, the instructions are placed under each other.

Why is it important to know? A statement is a unit of execution. An interpreter, which is the program that executes code in JavaScript, needs statements to be split in this way. It reads the file with the code, splits the code into statements, and then executes them. As developers, we must be able to recognize this order and mentally split the code into independent pieces that are easy to analyze.


Recommended materials

  1. About interpreters
  2. Statements and declarations by category

Sign up

Programming courses for beginners and experienced developers. Start training for free

  • 130 courses, 2000+ hours of theory
  • 1000 practical tasks in a browser
  • 360 000 students
By sending this form, you agree to our Personal Policy and Service Conditions

Our graduates work in companies:

Bookmate
Health Samurai
Dualboot
ABBYY