那一朵太阳花 发表于 2022-6-5 15:53:50

javascript

1:定义一个myJson函数,带有一个形参,处理传过来的JSON形如{name:'mike',age:18,address:'chengdu'},并返回name的值
求javascript中用parse方法如何写

wp231957 发表于 2022-6-5 19:55:48

var s2={name:'mike',age:18,address:'chengdu'};
console.log(s2["name"]);
var s1='{"name":"mike","age":18,"address":"chengdu"}';
var obj=JSON.parse(s1);
console.log(obj.age);
console.log(obj["age"]);
页: [1]
查看完整版本: javascript