Skip to content

Instantly share code, notes, and snippets.

@gilles-leblanc
Created April 13, 2013 01:11
Show Gist options
  • Save gilles-leblanc/5376386 to your computer and use it in GitHub Desktop.
Save gilles-leblanc/5376386 to your computer and use it in GitHub Desktop.
Undefined and exceptions
/** Undefined and exceptions
* Trying out code while reading JavaScript docs on MDN
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
<!-- content to be placed inside <body>…</body> -->
<div id="first-result"></div>
<div id="second-result"></div>
<div id="third-result"></div>
var a;
document.getElementById("first-result").innerHTML = "The value of a is " + a;
//Throws reference error
try {
document.getElementById("second-result").innerHTML = "The value of b is " + b;
}
catch (e) {
document.getElementById("second-result").innerHTML = e.name + ", " + e.message;
}
try {
throw Error("this is a test");
}
catch (e) {
document.getElementById("third-result").innerHTML = e.name + ", " + e.message;
}
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"javascript"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment