From 447e3467db3a94f3e84d6572038e2e803614f3e1 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Tue, 16 Jan 2018 16:50:21 +0200 Subject: [PATCH] Add isNil and isUndefined --- snippets/isNil.md | 14 ++++++++++++++ snippets/isUndefined.md | 13 +++++++++++++ tag_database | 2 ++ 3 files changed, 29 insertions(+) create mode 100644 snippets/isNil.md create mode 100644 snippets/isUndefined.md diff --git a/snippets/isNil.md b/snippets/isNil.md new file mode 100644 index 000000000..82618c36f --- /dev/null +++ b/snippets/isNil.md @@ -0,0 +1,14 @@ +### isNil + +Returns `true` if the specified value is `null` or `undefined`, `false` otherwise. + +Use the strict equality operator to check if the value and of `val` are equal to `null` or `undefined`. + +```js +const isNil = val => val === undefined || val === null; +``` + +```js +isNil(null); // true +isNil(undefined); // true +``` diff --git a/snippets/isUndefined.md b/snippets/isUndefined.md new file mode 100644 index 000000000..265b80e57 --- /dev/null +++ b/snippets/isUndefined.md @@ -0,0 +1,13 @@ +### isUndefined + +Returns `true` if the specified value is `undefined`, `false` otherwise. + +Use the strict equality operator to check if the value and of `val` are equal to `undefined`. + +```js +const isUndefined = val => val === undefined; +``` + +```js +isUndefined(undefined); // true +``` diff --git a/tag_database b/tag_database index 34a1c6e92..c25e9f023 100644 --- a/tag_database +++ b/tag_database @@ -89,6 +89,7 @@ isEven:math isFunction:type,function isLowerCase:string,utility isMap:type +isNil:type isNull:type isNumber:type,math isObject:type,object @@ -102,6 +103,7 @@ isString:type,string isSymbol:type isTravisCI:node isTypedArray:type +isUndefined:type isUpperCase:string,utility isValidJSON:type,json isWeakMap:type