源代码 :
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>开源教程(ossoft.cn)</title> </head> <body> <p>你也可以使用中括号([])来访问 JOSN 对象的值:</p> <p id="demo"></p> <script> var myObj, x; myObj = myObj = { "name":"runoob", "alexa":10000, "site":null }; x = myObj["name"]; document.getElementById("demo").innerHTML = x; </script> </body> </html>
运行结果