摆弄 javascript 和数组,并将其作为有效语法传递,如何?
var x = [asd = {a: 10, b: 20}]
这条线是为了满足问题的质量标准。
最佳答案
让我们分开看看:
您编写的代码可以更改为:
// it not have the `var` like other answer say
asd = {a: 10, b: 20}
var x = [asd]
但要小心使用它,它会导致全局定义变量。
如果在严格模式
下,这将不起作用,因为隐式定义全局是不允许的。
关于javascript - 这个有效语法如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35216619/