访问对象内的对象属性

首先看下面的JavaScript对象


var settings = {

  user:"someuser",

  password:"password",

  country:"Country",

  birthplace:country

}

我想将birthplace值设置为与相同country,因此我将对象值country放在前面,birthplace但它对我没有用,我也使用过this.country但仍然失败。我的问题是如何访问对象内对象的属性。


一些用户沉迷于询问“您想做什么或发送脚本等”,这些ppls的答案很简单:“我想访问对象内的对象属性”,并且上面提到了脚本。


三国纷争
浏览 315回答 3
3回答

萧十郎

您无法访问其内部的对象。您可以使用变量:var country = "country";var settings = {  user:"someuser",  password:"password",  country:country,  birthplace:country}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript