小编egr*_*ret的帖子

为什么JSON.stringify不显示作为函数的对象属性?

为什么JSON.stringify()不显示prop2?

var newObj = {
  prop1: true,
  prop2: function(){
    return "hello";
  },
  prop3: false
};

alert( JSON.stringify( newObj ) ); // prop2 appears to be missing

alert( newObj.prop2() ); // prop2 returns "hello"

for (var member in newObj) {
    alert( member + "=" + newObj[member] ); // shows prop1, prop2, prop3
}
Run Code Online (Sandbox Code Playgroud)

JSFIDDLE:http: //jsfiddle.net/egret230/efGgT/

javascript json function object stringify

8
推荐指数
2
解决办法
5518
查看次数

标签 统计

function ×1

javascript ×1

json ×1

object ×1

stringify ×1