Update isPrimitive.md
This commit is contained in:
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
Returns a boolean determining if the passed value is primitive or not.
|
Returns a boolean determining if the passed value is primitive or not.
|
||||||
|
|
||||||
Use `Array.prototype.includes()` on an array of type strings which are not primitive,
|
Create an object from `val` and compare it with `val` to determine if the passed value is primitive (i.e. not equal to the created object).
|
||||||
supplying the type using `typeof`.
|
|
||||||
Since `typeof null` evaluates to `'object'`, it needs to be directly compared.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const isPrimitive = val => Object(val) !== val;
|
const isPrimitive = val => Object(val) !== val;
|
||||||
|
|||||||
Reference in New Issue
Block a user