我有一个类似的对象
let axis = {
x: -1,
y: -1
}
我想创建另一个对象,
let node = {
//axis object's variable(1)
//axis object's variable(2)
//axis object's variable(3)
}
如何在javascript中创建上述对象?
答案 0 :(得分:1)
这是你的追求吗?
let axis = {
x: -1,
y: -1
}
let node = {
x: axis.x,
y: axis.y
}
console.log(node.x); // prints -1 to the console
console.log(node.y); // prints -1 to the console
答案 1 :(得分:-1)