Skip to content

Instantly share code, notes, and snippets.

@rodolfo42
Created March 14, 2014 18:40
Show Gist options
  • Save rodolfo42/9554032 to your computer and use it in GitHub Desktop.
Save rodolfo42/9554032 to your computer and use it in GitHub Desktop.
simple getOrElse in javascript
function getOrElse(value, _) {
var args = Array.prototype.slice.call(arguments);
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if(typeof arg != "undefined" && arg != null && !isNaN(arg)) {
return arg;
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment