Javascript - Error class reference

Introduction

The Error object provides error information when an error occurs.

Demo

try {
    adddlert("Welcome guest!");
}
catch(err) {/*w w w  . j ava  2 s  .co m*/
    console.log(err.name + "\n" + err.message);
}

Result

Error Object Properties

Property Description
name Sets or returns an error name
message Sets or returns an error message (a string)