所以我想知道是否/如何在对象ex中使用对象中的值作为arg:
var mousePos = {
chaos: (-950, 22)
}
console.log(mousePos.chaos) // chaos
mouse.Move(mousePos.chaos) // which would take two args, and then output Invalid number of arguments.
最佳答案
我认为您正在寻找数组和spread syntax:
var mousePos = {
chaos: [-950, 22]
};
console.log(mousePos.chaos) // [-950, 22]
mouse.move(...mousePos.chaos) // equivalent to `mouse.move(-950, 22)`