HTML DOM console.error() method
- Previous Page count()
- Next Page group()
- Go to the Previous Level Window Console Object
Definition and usage
The console.error() method writes error messages to the console.
The console is very useful for testing.
Tip:When testing this method, make sure the console view is visible (press F12 to view the console).
Instance
Example 1
Write to the console:
console.error("You made a mistake");
Example 2
Use an object as an error message:
var myObj = { firstname : "Bill", lastname : "Gates" }; console.error(myObj);
Example 3
Use an array as an error message:
var myArr = ["Orange", "Banana", "Mango", "Kiwi" ]; console.error(myArr);
Syntax
console.error(message)
Parameter value
Parameter | Type | Description |
---|---|---|
message | String or Object | Required. As an error message or object to be written. |
Browser Support
The numbers in the table indicate the first browser version that fully supports this method.
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
console.error() | Support | 8.0 | 4.0 | Support | Support |
- Previous Page count()
- Next Page group()
- Go to the Previous Level Window Console Object