Assert in JavaScript

function assert(condition, message) {
    if (!condition) {
        throw new Error(message || "assert failed");
    }
}

source