19 lines
467 B
Markdown
19 lines
467 B
Markdown
### isPrimitive
|
|
|
|
Returns a boolean determining if the passed value is primitive or not.
|
|
|
|
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).
|
|
|
|
```js
|
|
const isPrimitive = val => Object(val) !== val;
|
|
```
|
|
|
|
```js
|
|
isPrimitive(null); // true
|
|
isPrimitive(50); // true
|
|
isPrimitive('Hello!'); // true
|
|
isPrimitive(false); // true
|
|
isPrimitive(Symbol()); // true
|
|
isPrimitive([]); // false
|
|
```
|