Assertions
assert.strictEqual()
Compares values using Object.is semantics. For example NaN compares equal to itself while positive and negative zero differ. Objects compare by identity, not recursively. Tested on Node.js 22.16.0. Example output (one line per entry): ["ERR_ASSERTION"].
Formal Syntax & Structure
nodejs syntaxnodejs
assert.strictEqual(actual, expected[, message])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| actual | any | Observed value. |
| expected | any | Required value. |
| message | string | Error | Failure detail. |
Return Value
undefined
Returns normally or throws.
Working Example
Example Snippetnodejs
import assert from 'node:assert/strict';assert.strictEqual(NaN, NaN);try { assert.strictEqual(0, -0);}catch (e) { console.log(e.code);}