Avoid confusing prototype methods for static methods
Correct: `Array.from()` (it’s a static method) Incorrect: `Array.join()` (doesn’t exist; it’s a prototype method) This patch uses the common `#` syntax to denote `.prototype.`.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
Checks if the provided value is of the specified type.
|
||||
|
||||
Ensure the value is not `undefined` or `null` using `Array.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()`, and 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;
|
||||
|
||||
Reference in New Issue
Block a user