Using Console.Assert To Print Out An Assertion To The Console

[!INFO]-
topic: πŸ–₯️ Tech
links:

source: Tips and Tricks for Debugging JavaScript - YouTube
tags: #permanent-noteΒ #published

Last Modified: =dateformat(this.file.mtime, "MMM. dd, yyyy - HH:mm")


Instead of using console.log, you can print out an assertion with console.assert. The first parameter is the assertion and the second one is the message you want to print as an error (similar to console.error, if the assertion failed.

console.assert(value !== undefined, "This shouldn't be undefined");