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