Why can't you stringify a function expression?

后端 未结 5 1468
醉话见心
醉话见心 2020-12-30 01:06

Why doesn\'t this produce anything?

console.log(JSON.stringify(function(){console.log(\'foobar\');}));
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-30 01:41

    You cannot do that, but there are some third party libraries can help you do that, like: https://www.npmjs.com/package/json-fn

提交回复
热议问题