JavaScripr console.assert() Method
- All values are truthy unless they are defined as falsy
- Falsy value is a value that evaluates to FALSE
If the passed value is falsy in that case, the method logs/prints the extra arguments passed after the first argument, otherwise, the code execution continues without any log.
Syntax: console.assert(expression, message)
- expression – any expression. If an expression evaluates to false, an error message is written to the console. Else it will print nothing if the expression evaluates to true.
- message – The message to be displayed in the console.
What we discussed above is given in the below example.
Output: Run the above code, and then press the F12 key and go to the Console tab as shown in the below image.
About the Author: Pranaya Rout
Pranaya Rout has published more than 3,000 articles in his 11-year career. Pranaya Rout has very good experience with Microsoft Technologies, Including C#, VB, ASP.NET MVC, ASP.NET Web API, EF, EF Core, ADO.NET, LINQ, SQL Server, MYSQL, Oracle, ASP.NET Core, Cloud Computing, Microservices, Design Patterns and still learning new technologies.