HTML DOM console.assert( ) Method Last Updated : 30 Aug, 2024 Comments Improve Suggest changes Like Article Like Report The console.assert() method in HTML is used to write a message for the user on the console only if the expression evaluates to false. The expression and the message are sent as parameters to the console.assert() method. Syntax:console.assert( expression, message )Parameters: This method accepts two parameters as mentioned above and described below:expression: A Boolean expression denotes the message or object to write to the console. It is a required parameter.message: A string or object denotes the message or object to write to the console. It is a required parameter.Example 1: Below program illustrates the console.assert() method in HTML HTML <!DOCTYPE html> <html> <head> <title> DOM console.assert() Method </title> <style> h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM console.assert() Method</h2> <p> To view the message in the console press the F12 key on your keyboard. </p> <script> console.assert(document.getElementById("MyElement"), "There is no element with the ID 'MyElement'"); </script> </body> </html> Output:Example 2: Displaying an object while using the console.assert() method HTML <!DOCTYPE html> <html> <head> <title>DOM console.assert() Method</title> <style> h1 { color: green; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM console.assert( ) Method</h2> <p> To view the message in the console press the F12 key on your keyboard. </p> <script> let MyElement = { Product: "Coca Cola", Type: "Beverage" }; console.assert(document.getElementById("MyDemo"), MyElement); </script> </body> </html> Output:Supported Browsers: The browser is supported by the console.assert() method are listed below:Google ChromeEdge FirefoxOperaSafari Comment More infoAdvertise with us Next Article HTML DOM console.assert( ) Method S Shubrodeep Banerjee Follow Improve Article Tags : Web Technologies HTML HTML-DOM Similar Reads HTML DOM body Property The HTML DOM Body property is used to set the document <body> element. It only returns the content present in the <body> Tag. This property is used to change the present content inside the <body> element and sets them with the new specified content. This property does not return th 2 min read HTML DOM createAttribute() Method This createAttribute() method is used to create an attribute with the specified name and returns the attribute object. The attribute.value property is used to set the value of the attribute and the element.setAttribute() method is used to create a new attribute for an element. This method() contains 2 min read HTML DOM doctype Property The DOM doctype property is used to return the doctype of any HTML document. The DocumentType object is the name property used to return the name of the object. If there is no doctype declared in the document then it returns a Null value. Syntax:document.doctypeExample: In this example, we will use 2 min read HTML DOM writeln() Method The writeln() method is used to write a document with the additional property of a newline character after each statement. This method is similar to the document.write() method. Syntax: document.writeln( exp1, exp2, exp3, ... )Parameters: This method contains many parameters which are optional. All 1 min read HTML DOM console error() Method The console.error() method in HTML is used to display an error message on the console. The console.error() method is used for testing purposes. The error message is sent as a parameter to the console.error() method. Syntax:console.error( message )Parameters: This method accepts a single parameter me 2 min read HTML DOM console groupCollapsed() Method The console.groupCollapsed() method in HTML is used to create a collapsed group of messages in the console. It indicates the start of a collapsed message group and all the messages written after calling the console.groupCollapsed() method will write inside the message group. The label is sent as an 2 min read HTML DOM console count() Method The console.count() method in HTML is used to write the number of times the console.count() method is called. The console.count() method can be added to a label that will be included in the console view. The label is an optional parameter sent to the console.count() method. Syntax:console.count( lab 2 min read HTML DOM console clear() Method The console.clear() method in HTML is used to clear the console and writes some message "Console was cleared" on the console whenever it is executed. This method does not require any parameter. Syntax:console.clear()Example: The below program illustrates the console.clear() method in HTML:HTML<!D 2 min read HTML DOM createTextNode() Method The createTextNode() method is used to create a TextNode which contains an element node and a text node. It is used to provide text to an element. This method contains the text values as parameters which are of string type.Syntax: document.createTextNode( text )Parameters: This method accepts single 2 min read HTML DOM console table() Method The console.table() method in HTML is used for writing data in tabular form in the console view. The table data is sent as a parameter to the console.table() method which must be an object or an array containing the data to be filled in the table. Syntax:console.table( tabledata, tablecolumns );Para 3 min read Like