Page MenuHomePhorge

json_stringify_nested_function_replacer.cjs
No OneTemporary

Size
339 B
Referenced Files
None
Subscribers
None

json_stringify_nested_function_replacer.cjs

const obj = {
action() {
return 1;
},
child: {
inner() {
return 2;
},
},
missing: undefined,
};
const out = JSON.stringify(obj, (_key, value) => {
if (typeof value === 'function') return `[fn:${value.name || 'anonymous'}]`;
if (value === undefined) return '[undef]';
return value;
});
console.log(out);

File Metadata

Mime Type
application/javascript
Expires
Fri, Apr 3, 5:10 PM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
521545
Default Alt Text
json_stringify_nested_function_replacer.cjs (339 B)

Event Timeline