Created
December 11, 2015 19:27
-
-
Save tlkahn/0783251cf145620cd30a to your computer and use it in GitHub Desktop.
javascript assert function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function assert(condition, message) { | |
if (!condition) { | |
message = message || "Assertion failed"; | |
if (typeof Error !== "undefined") { | |
throw new Error(message); | |
} | |
throw message; // Fallback | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment