gpt4 book ai didi

javascript - 是否可以在 Javascript 的变量名中添加两个点?

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

我想在 javascript 中创建一个这样的变量

variable1.varible2.variable3 = "Hi Its working";
alert(variable1.varible2.variable3);

最佳答案

变量名中不能有 .

You can call a variable pretty much anything you like, but there are limitations. Generally, you should stick to just using Latin characters (0-9, a-z, A-Z) and the underscore character.

如果您确实希望 variable1.varible2.variable3 返回值 "Hi Its working"。您可以使用对象。

let variable1 = {
variable2:{
variable3:"Soemthing"
}
}
console.log(variable1.variable2.variable3)

关于javascript - 是否可以在 Javascript 的变量名中添加两个点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55783710/

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