console.assert(condition, message) Last updated: 30. May 2026

This function checks if a certain condition is false. If it is, outputs an error message and throws an exception with the message.

Parameters

Name Type Description
condition bool

The condition to test. If it evaluates to false, the assertion fails.

message string

The error message to output and throw if the condition is false.

Returns

Null if condition is true, throws an exception if it is false with the specified message as error message.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
// Testing addition and multiplication
let result = 2 + 3 * 4;
console.assert(result === 14, `Expected 14, but got ${result}`);