Sys.Debug assert Method
Checks for a condition, and if the condition is false, displays a message and prompts the user to break into the debugger.
When you call the assert method in your code, express the success of an operation as true or false and use that value for condition. If the operation fails (if condition is false), the assert logic is executed.
The assert method should be used to catch developer errors. To respond to user errors and to run-time error conditions such as network errors or permission failures, throw an exception.
Debugging behavior, requirements, and the output of trace messages vary with different browsers. For more information, see Debugging and Tracing Ajax Applications Overview.
The following example shows a function that calls the assert method if the user-defined variable n is not a positive integer. This is part of a larger example from the Sys.Debug class overview.