HTML JS

HOW TO SHOW ERROR MESSAGES IN JAVASCRIPT

Javascript errors will show in the developer's console by default. Press F12 in most major browsers to bring it up.

TO OUPUT MESSAGES IN THE CONSOLE console.log("MESSAGE"); console.error("MESSAGE");

DEVELOPER'S CONSOLE

01

try { DO SOMETHING } catch (e) { alert(e); }

ALERT POPUP BOX

02

<div id="err"></div>

try { DO SOMETHING } catch (e) {   let err = document.getElementById("err");   err.innerHTML = e;   }

HTML ERROR MESSAGE

03