79415763

Date: 2025-02-05 18:14:55
Score: 0.5
Natty:
Report link

Whatever you do, don't do this.

Map.prototype.toJSON = function() {
    return Object.fromEntries(this);
};

const map = new Map();
map.set('a', 1);
map.set('b', { datum: true });
map.set(false, [1, 2, 3]);
map.set('d', new Map([['e', true]]) );

const json = JSON.stringify(map);

console.log(json);

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: MJ Walsh