console.log('startX:'+startX,'startY:'+startY)
var pixelStack=[[startX, startY]]; //create pixel stack with starting pixel on top
console.log('pxStack:'+pixelStack)
var test=[[startX, startY]];
console.log('test:'+test)
pixelStack=test
console.log(pixelStack,test)
当我运行这段代码(它包含在一个函数中)时,测试被正确定义,但是pixelStack被定义为一个空数组([]),当我运行pixelStack = test时,它们都变成一个空数组。这是我的控制台输出:
startX:250 startY:250
pxStack:250,250
测试:250,250
[] []
(我在Google Chrome中)