Skip to content

Instantly share code, notes, and snippets.

@fatihbahceci
Created March 9, 2019 09:26
Show Gist options
  • Save fatihbahceci/c4680b27c16ef3cef1a9c3889440fb6b to your computer and use it in GitHub Desktop.
Save fatihbahceci/c4680b27c16ef3cef1a9c3889440fb6b to your computer and use it in GitHub Desktop.
javascript null-coalescing function
function isNull() {
for (var i = 0; i < arguments.length; i++) {
if (
typeof arguments[i] !== 'undefined'
&& arguments[i] !== undefined
&& arguments[i] != null
&& arguments[i] != NaN
&& arguments[i]
) return arguments[i];
}
}
//test
console.log(isNull(null, null, undefined, 'Target'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment