Assert method : assert : Development JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Development » assert »

 

Assert method

















<html>
<head>
<title>Debug Example</title>
<script type="text/javascript">
  function assert(bCondition, sErrorMessage) {
      if (!bCondition) {
          alert(sErrorMessage);
          throw new Error(sErrorMessage);
      }
  }


  function aFunction(i) {
      assert(false, "1==2");
  }

  aFunction(1);


</script>
</head>
<body>
    <P>This page uses assertions to throw a custom JavaScript error.</p>
</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Development
» assert