maybe

// Maybe combinator // https://leanpub.com/javascript-allonge/read#maybe function maybe(fn) { return function () { var i; if (arguments.length === 0) { return; } for (i = 0; i < arguments.length; ++i) { if (arguments[i] === null) return } return fn.apply(this, arguments) } } // Only executes logic for non null|undefined|empty|NaN values var checksForSomething = maybe(function (value) { // Truthy logic here console.log(value); });

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.