这个问题以前可能已经问过了,但我能找到的都是关于C和Bash等的问题。
基本上,我很难理解函数参数和它们引用的内容。
我知道你通常在调用函数时设置参数,例如doSomething(3,'Hello')等,但当我从教程中阅读代码时,就会这样;
window.onload = initAll;
function initAll() {
if (document.getElementById) {
for (var i=0; i<24; i++) {
setSquare(i);
}
}
else {
alert("Sorry, your browser doesn't support this script");
}
}
function setSquare(thisSquare) {
var currSquare = "square" + thisSquare;
var colPlace = new Array(0,0,0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4);
var colBasis = colPlace[thisSquare] * 15;
var newNum = colBasis + getNewNum() + 1;
document.getElementById(currSquare).innerHTML = newNum;
}
function getNewNum() {
return Math.floor(Math.random() * 15);
}thisSquare的参数setSquare()是从哪里获取的?
发布于 2012-01-10 06:25:13
在本例中,它是从initAll()函数中的for循环中获取的,但也可以从调用setSquare函数的任何地方获取
https://stackoverflow.com/questions/8795952
复制相似问题