In the development and maintenance process of JavaScript programs, Assert is a good feature used to ensure the correctness of the program. On browsers with debugging tools, this feature can be achieved by calling console.assert(). For example, in the following code, the console.assert() statement ensures that the score variable value length of the cat object is 3:
After the code is executed, the Firebug console will print the error message:
Browser support
console.assert() is better supported on browsers with debugging tools, and all major browsers support this function. However, it is worth mentioning that Firefox itself does not support this function. The Firebug plug-in must be installed on Firefox to use console.assert().