'How to make an analogue of Array.isArray() for Map in JS?
I'm researching prototypes in JS.
- Please tell me how to add the Map.isMap(object) function to the Map prototype.
I was able to make object.isMap() by code:
Map.prototype.isMap = function() {
return this.__proto__.toString().toLowerCase().includes("map");
}
- I know editing prototype chain is a bad practice in JS. What is the best way to create such function?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
