Difference between revisions of "Console.assert"

From FirebugWiki
Jump to: navigation, search
(Separate Console API page for console.assert())
m (Added categories)
Line 29: Line 29:
== See also ==
== See also ==
* [[Console API]]
* [[Console API]]

Latest revision as of 16:09, 21 November 2013

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]