Skip to content

Instantly share code, notes, and snippets.

@tlkahn
Created December 11, 2015 19:27
Show Gist options
  • Save tlkahn/0783251cf145620cd30a to your computer and use it in GitHub Desktop.
Save tlkahn/0783251cf145620cd30a to your computer and use it in GitHub Desktop.
javascript assert function
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