assert - Debug an Expression in JavaScript

Assert function is commonly used for debugging, if the input expression does not evaluate to TRUE, this function throws an exception with custom error message.

<script type="text/javascript">

//Custom Assert Function
function assert(bCondition, sErrorMessage) {
    if (!bCondition) {
        throw new Error(sErrorMessage);
// Expression returning FALSE, it throws exception
assert(1==2,"It is a error");

// Expression returning TRUE
assert(1==1,"It is a not an error");