gpt4 book ai didi

javascript - 这段代码有什么问题? (JavaScript 对象)

转载 作者:行者123 更新时间:2023-11-30 19:34:19 25 4
gpt4 key购买 nike

const address = {
street: 'Dique 3',
city: 'Santa Cruz',
zipcode: 38320,
function showAddress {
console.log(`${this.street}, ${this.city}, ${this.zipcode}`)
}
}

address.showAddress();

最佳答案

您以错误的方式添加了方法。

const address = {
street: 'Dique 3',
city: 'Santa Cruz',
zipcode: 38320,
showAddress(){
console.log(`${this.street}, ${this.city}, ${this.zipcode}`)
}
}

address.showAddress();

关于javascript - 这段代码有什么问题? (JavaScript 对象),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56100850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com