Created
July 6, 2020 18:09
-
-
Save funfunction/0e64a5aa3abedfa237823d0bab2ef70b to your computer and use it in GitHub Desktop.
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
/** | |
@func | |
true if var is null or undefined | |
@param {*} v | |
@return {boolean} | |
*/ | |
export const isNil = v => v === undefined || v === null; | |
//@tests | |
const aTrue = [undefined, null, (() => undefined)(), (() => null)(), (() => console.log())()]; | |
const aFalse = ["", [], {}, () => undefined, "undefined", "null", NaN, -Infinity, 9e9999, 9999n]; | |
logForeachParam(isNil)(aTrue); | |
logForeachParam(isNil)(aFalse); | |
// logForeachParam sourcecode at: https://gist.github.com/funfunction/42918a4751ae51828cfc4c2dd4c0678e | |
/** | |
@func complement | |
@param {*} v | |
@return {boolean} | |
*/ | |
export const isNotNil = v => !isNil(v); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment