Console.assert

From FirebugWiki

Jump to: navigation, search

Tests whether an expression is true. If not, it will write a message to the console and throw an exception. In case there more parameters provided the ones starting from the second will build the assertion message.

The log also includes the stack trace of the error in case the Console panel option Show Stack Trace With Errors is enabled.

Contents

[edit] Syntax

console.assert(expression[, object, ...])

[edit] Parameters

[edit] expression

Assertion expression. Failing expressions are false, 0, null, or undefined.

[edit] object

Object to use for the assertion message. If no object is provided, "Assertion Failure" will be displayed as default message.

[edit] Examples

console.assert(var1 === var2);

This prints Error.png Assertion Failure to the console.

console.assert(var1 === var2, "Variables are not equal");

This prints Error.png Variables are not equal to the console.

[edit] See also

Personal tools