Update snippet descriptions

This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-20 23:02:01 +03:00
parent 52880f08ee
commit caa67e2a49
63 changed files with 175 additions and 126 deletions

View File

@@ -1,11 +1,12 @@
---
title: is
tags: type,array,regexp,beginner
tags: type,array,intermediate
---
Checks if the provided value is of the specified type.
- Ensure the value is not `undefined` or `null` using `Array.prototype.includes()`, and compare the `constructor` property on the value with `type` to check if the provided value is of the specified `type`.
- Ensure the value is not `undefined` or `null` using `Array.prototype.includes()`.
- Compare the `constructor` property on the value with `type` to check if the provided value is of the specified `type`.
```js
const is = (type, val) => ![, null].includes(val) && val.constructor === type;