![]() |
VOOZH | about |
JavaScript statements are programming instructions that a computer executes. A computer program is essentially a list of these "instructions" designed to perform tasks. In a programming language, such instructions are called statements.
In JavaScript, you can declare variables using var, let, or const. let and const are used in modern JavaScript for block-scoped variables, while var is function-scoped and generally considered outdated.
An assignment statement is used to assign a value to a variable. You can assign any type of value, including strings, numbers, and objects, using the assignment operator =.
An expression in JavaScript is any valid unit of code that resolves to a value. When an expression is executed, it can perform an action (e.g., calculation, function call) and return a result. An expression can also be used as a statement.
Control flow statements are used to control the order in which statements are executed in a program. Examples include if, else, switch, while, and for loops.
A function declaration is a statement that defines a function in JavaScript. Functions are reusable blocks of code designed to perform specific tasks.
The return statement is used to exit a function and optionally pass a value back to the calling code.
The throw statement is used to create custom errors in JavaScript. It is often used in conjunction with try...catch to handle errors.
The try...catch statement is used to handle exceptions in JavaScript. The code inside the try block is executed, and if an error occurs, the code inside the catch block will handle the error.
The break and continue statements are used within loops. break exits the loop, while continue skips to the next iteration.
Keyword | Description |
|---|---|
Used to declare a variable | |
Used to declare a block variable | |
Used to declare a block constant | |
Used to decide if certain block will get executed or not | |
Executes a block of codes depending on different cases | |
Executes a block of statements till the condition is true | |
Used to declare a function | |
Used to exit a function | |
Used to handle errors in a block of statements | |
Used to terminate a loop | |
Used to continue a loop |