---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# console.assert()

The **`console.assert()`** method writes an error message to
the console if the assertion is false. If the assertion is true, nothing happens.

## Syntax

```js
assert(assertion, obj1)
assert(assertion, obj1, obj2)
assert(assertion, obj1, obj2, /* … ,*/ objN)

assert(assertion, msg)
assert(assertion, msg, subst1)
assert(assertion, msg, subst1, /* … ,*/ substN)
```

### Parameters

- `assertion`
  - : Any boolean expression. If the assertion is false, the message is written to the
    console.
- `obj1` … `objN`
  - : A list of JavaScript objects to output. The string representations of each of these
    objects are appended together in the order listed and output.
- `msg`
  - : A JavaScript string containing zero or more substitution strings.
- `subst1` … `substN`
  - : JavaScript objects with which to replace substitution strings within
    `msg`. This parameter gives you additional control over the format of the
    output.

### Return value

`undefined`.
