首先看下面的JavaScript对象var settings = { user:"someuser", password:"password", country:"Country", birthplace:country}我想将birthplace值设置为与相同country,因此我将对象值country放在前面,birthplace但它对我没有用,我也使用过this.country但仍然失败。我的问题是如何访问对象内对象的属性。一些用户沉迷于询问“您想做什么或发送脚本等”,这些ppls的答案很简单:“我想访问对象内的对象属性”,并且上面提到了脚本。
3 回答

萧十郎
TA贡献1815条经验 获得超13个赞
您无法访问其内部的对象。您可以使用变量:
var country = "country";
var settings = {
user:"someuser",
password:"password",
country:country,
birthplace:country
}
添加回答
举报
0/150
提交
取消