diff --git a/README.md b/README.md index ff6785450..d056ac44a 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,7 @@ * [`isArray`](#isarray) * [`isBoolean`](#isboolean) * [`isFunction`](#isfunction) +* [`isNull`](#isnull) * [`isNumber`](#isnumber) * [`isString`](#isstring) * [`isSymbol`](#issymbol) @@ -3994,6 +3995,29 @@ isFunction(x => x); // true
[⬆ Back to top](#table-of-contents) +### isNull + +Returns `true` if the specified value is `null`, `false` otherwise. + +Use the strict equality operator to check if the value and of `val` are equal to `null`. + +```js +const isNull = val => val === null; +``` + +
+Examples + +```js +isNull(null); // true +isNull('null'); // false +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### isNumber Checks if the given argument is a number. diff --git a/docs/index.html b/docs/index.html index 9a4bea5ee..2c46f0eeb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -59,7 +59,7 @@ wrapper.appendChild(box); box.appendChild(el); }); - }

 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
+    }

 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
 
Promise.resolve([1, 2, 3])
   .then(call('map', x => 2 * x))
   .then(console.log); //[ 2, 4, 6 ]
@@ -828,6 +828,9 @@ isBoolean(false); // true
 

isFunction

Checks if the given argument is a function.

Use typeof to check if a value is classified as a function primitive.

const isFunction = val => val && typeof val === 'function';
 
isFunction('x'); // false
 isFunction(x => x); // true
+

isNull

Returns true if the specified value is null, false otherwise.

Use the strict equality operator to check if the value and of val are equal to null.

const isNull = val => val === null;
+
isNull(null); // true
+isNull('null'); // false
 

isNumber

Checks if the given argument is a number.

Use typeof to check if a value is classified as a number primitive.

const isNumber = val => typeof val === 'number';
 
isNumber('1'); // false
 isNumber(1); // true
diff --git a/snippets/isNull.md b/snippets/isNull.md
index 353dff34d..1bed08c4d 100644
--- a/snippets/isNull.md
+++ b/snippets/isNull.md
@@ -9,6 +9,6 @@ const isNull = val => val === null;
 ```
 
 ```js
-isNull(null) // true
-isNull('null') // false
+isNull(null); // true
+isNull('null'); // false
 ```