topical media & game development
professional-javascript-14-DebugExample4.htm / htm
<html>
<head>
<title>Debug Example</title>
<script type="text/javascript">
function divide(iNum1, iNum2) {
if (arguments.length != 2) {
throw new Error("divide() requires two arguments.");
} else if (typeof iNum1 != "number" || typeof iNum2 != "number") {
throw new Error("divide() requires two numbers for arguments.");
}
return iNum1.valueOf() / iNum2.valueOf();
}
alert(divide("a"));
</script>
</head>
<body>
<p>This page throws a custom JavaScript error.</p>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.