From FirebugWiki
Revision as of 16:09, 21 November 2013 by Sebastianz (Talk | contribs) (Added categories)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.


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



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


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


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.

See also[edit]