JavaScript Statement Referentie Handleiding

JavaScript statements

In HTML zijn JavaScript-uitingen de "aanwijzingen" die de webbrowser moet "uitvoeren".

Deze zin vertelt de browser om "Hello Kitty" te schrijven in het HTML-element met id="demo":

Example

document.getElementById("demo").innerHTML = "Hello Kitty";

Try It Yourself

For more information about statements, please read our JavaScript Statement Tutorial.

JavaScript Statement Identifiers

JavaScript statements usually start with a statement identifier to indicate the JavaScript action to be executed.

Statement identifiers are reserved words and cannot be used as variable names (or anything else).

The following table lists all JavaScript statement identifiers:

Statement Description
break Exit the switch or loop.
class Declare a class.
const Declare a variable with a constant value.
continue If a specified condition occurs, interrupt the loop (in the loop) once and continue to the next iteration in the loop.
debugger Stop executing JavaScript and call the debugging feature (if available).
do ... while Execute a statement block and repeat the statement block when the condition is true.
for Loop through a code block multiple times.
for ... in Loop through the properties of an object.
for ... of Loop through the values of an iterable object.
function Declare a function.
if ... else ... else if Mark a statement block to be executed based on a condition.
let Declare a variable within the scope of the braces {}.
return Stop executing the function and return a value from the function.
switch Mark a statement block to be executed based on different conditions.
throw Throw (generate) an error.
try ... catch ... finally Mark a statement block to be executed when an error occurs in the try block, and implement error handling.
var Declare a variable.
while Statement block to be executed when the condition is marked as true.