Skip to content

Instantly share code, notes, and snippets.

@nosajio
Last active April 29, 2016 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nosajio/5472684 to your computer and use it in GitHub Desktop.
Save nosajio/5472684 to your computer and use it in GitHub Desktop.
A useful little unless function written in javascript.
/**!
* Unless
* @created April 2013 by @jasonhowmans
*/
var unless = function( condition, callback ) {
if (typeof callback === 'function') {
if (!condition) callback();
}else{
return !condition;
}
};
@nosajio
Copy link
Author

nosajio commented Apr 27, 2013

Here's a fiddle with a really basic test case: http://jsfiddle.net/jasonhowmans/VMLYE/3/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment