完整代码:
function foo1(){
return {msg: "hello1"};
}
function foo2(){
return
{msg: "hello2"};
}
// output = "foo1 = {"msg":"hello1"}"
console.log('foo1 = ' , JSON.stringify(foo1()));
//output = " foo2 = undefined "
console.log('foo2 = ' , JSON.stringify(foo2()));
两者之间的区别在于,在foo2中,{msg: 'hello'}它位于自己的新行中。我期待解析器忽略空格?
慕哥6287543
相关分类