JavaScript 中的对象是什么?如何访问任何属性?**
javascriptobject oriented programmingprogramming更新于 2025/8/8 2:20:17
访问对象的属性
没有对象就没有 JavaScript。布尔值、数字、函数等都是对象。以下方法解释了如何访问对象的属性。
示例 1
<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
示例 2
<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
相关文章
有用资源
javascript 参考教程 - 该教程包含有关 javascript 的更多信息:https://www.cainiaomax.com/javascript/

