Skip to content

Instantly share code, notes, and snippets.

@adrianratnapala
Created October 4, 2011 05:25
Show Gist options
  • Save adrianratnapala/1260963 to your computer and use it in GitHub Desktop.
Save adrianratnapala/1260963 to your computer and use it in GitHub Desktop.
Javascript assert() implementation in 6 lines.
function AssertFailed(message) {
this.toString = function() { return 'AssertFailed: ' + message; }
}
function assert(exp, message) {
if (!exp) throw new AssertFailed(message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment