The JavaScript function
function tile(u,v, a,b,c,d) {
var c0 = tileCorners[a].eval(u,v);
var c1 = tileCorners[b].eval(u-1,v);
var c2 = tileCorners[c].eval(u,v-1);
var c3 = tileCorners[d].eval(u-1,v-1);
return c0 + c1 + c2 + c3;
}
should be equivalent to
function tile(u,v, a,b,c,d) {
return
tileCorners[a].eval(u,v) +
tileCorners[b].eval(u-1,v) +
tileCorners[c].eval(u,v-1) +
tileCorners[d].eval(u-1,v-1);
}
yet the second function always returns undefined (the debugger will not “step into” the calls to eval) whereas the first function behaves correctly.
Is there something about having multiple eval method calls in an expression that is wrong?
You’re a victim of the rules of semicolon insertion.
Try:
Your version is equivalent to: