I'm trying to learn js and trying to extend a Map
. I did:
function mapExtend(mapInstance) {
function MapExtend(){
}
MapExtend.prototype = Object.create(Map.prototype);
MapExtend.prototype.constructor = MapExtend;
return new MapExtend(mapInstance)
}
And I did this:
const b = new Map()
mapExtend(b).get(1)
I'm getting the following error:
Uncaught TypeError: Method Map.prototype.get called on incompatible receiver #<MapExtend>
at MapExtend.get (<anonymous>)
at <anonymous>:1:14
What mistake i'm doing here?