![](/img/trans.png)
[英]FIrebase or object/Array- how to add a number/value to a variable without using the variable value?
[英]How can i re-initalise some variable with object value,to array of object without using another variable
我有一个名为 obj 的变量。如果我想拥有 object 的数组,我将使用另一个变量,例如:
let obj = {
name:"John"
}
let arr = [obj];
console.log(arr);
我会得到
[
{ name:"John"}
]
是否有任何 ES6 JS 简写,而不使用另一个变量?
例如,如果我只有
let obj = {
name:"John"
}
我怎样才能得到
[
{ name:"John"}
]
不使用另一个变量
很难说出你在问什么,但这会创建你只用一个变量创建的东西:
let arr = [{ name:"John"}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.