HTML DOM console.error() method

WBOY
Release: 2023-09-12 14:01:01
forward
1260 people have browsed it

HTML DOM The console.error() method is used to write error messages to the console. This method is great for testing and debugging.

Syntax

The syntax of the console.error() method is as follows:

console.error(console.error(message))
Copy after login

Here, message is a JavaScript string or object. It is a required parameter value.

Example

Let’s see an example about the HTML DOM console.error() method −

   

console.error() Method

Click the below button to write object as error message on the console

Press F12 key to view the error message in the console

Copy after login

Output

This will produce the following output−

HTML DOM console.error() 方法

Click the ERROR button and view the Console tab in Developer Tools−

HTML DOM console.error() 方法

In the example above−

We first created a button named ERROR. When the user clicks, the errMessage() function will be executed −

Copy after login

The errMessage() method creates a button with membersMessageand objects ofValueand their respective values. This object is then passed as a parameter to the error() method of the console object. The console's console.error() method prints the object as an error message to the console −

function errMessage(){ var errObj = { Message:"ERROR has been caused",Value:"NEGATIVE"}; console.error(errObj); }
Copy after login

The above is the detailed content of HTML DOM console.error() method. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!