Created
March 9, 2019 09:26
-
-
Save fatihbahceci/c4680b27c16ef3cef1a9c3889440fb6b to your computer and use it in GitHub Desktop.
javascript null-coalescing function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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