Mega Code Archive

 
Categories / JavaScript Tutorial / Development
 

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>