没有对象,就没有JavaScript。布尔值,数字,函数等所有内容都是对象。访问对象的属性在以下方法中进行了说明。
<html> <body> <script> myObj = {"name":"Ramesh","age":30,"family": [{"mother":"Geetha","father":"Rao"}],"city":"Berlin"}; var res = myObj.family[0].mother; document.write(res); </script> </body> </html>
Geetha
<html> <body> <script> myObj = {"name":"Ramesh","age":30,"family": [{"mother":"Geetha","father":"Rao"}],"city":"Berlin"}; var res = myObj.city; document.write(res); </script> </body> </html>
Berlin