Met Console Assert
# HTML DOM console.assert() Method
[ Console Object](#)
## Example
If the first parameter is false, output a message to the console:
console.assert(document.getElementById("demo"), "There is no element with ID 'demo'");
[Try it Yourself Β»](#)
* * *
## Definition and Usage
The console.assert() method writes a message to the console if the first parameter is false.
* * *
## Syntax
console.assert(expression, message)
* * *
## Browser Support
The numbers in the table specify the first browser version that fully supports the method.
| Method | | | | | |
| --- | --- | --- | --- | --- | --- |
| console.assert() | Yes | Yes | 28 | Yes | Yes |
* * *
## Parameter Values
| Parameter | Type | Description |
| --- | --- | --- |
| _expression_ | Boolean expression | Required. A boolean expression that returns true or false. |
| _message_ | String or Object | Required. The message or object to write to the console. |
* * *
## More Examples
## Example
Write an object to the console:
var myObj = {name: "", site: "www."}; console.assert(document.getElementById("demo"), myObj);
[Try it Yourself Β»](#)
## Example
Write an array to the console:
var myArr = ["Google", "Taobao", "", "Facebook"]; console.assert(document.getElementById("demo"), myArr);
[Try it Yourself Β»](#)
[ Console Object](#)
YouTip