This chapter contains information that is useful when reading this book.
There are two ways in which you can read this book:
This book was written with both ways in mind, so skipping content should not be a problem. If, at any point, there is relevant information elsewhere in the book, I point to it.
The following import is always assumed to have been made (similarly to how non-strict assert
is available in the Node.js REPL):
import * as assert from 'node:assert/strict';
This module implements assertions – which are often used in examples in this book. This is what they look like:
// Comparing primitive values:
.equal(3 + 4, 7);
assert.equal('abc'.toUpperCase(), 'ABC');
assert
// Comparing objects:
.notEqual({prop: 1}, {prop: 1}); // shallow comparison
assert.deepEqual({prop: 1}, {prop: 1}); // deep comparison
assert.notDeepEqual({prop: 1}, {prop: 2}); // deep comparison assert