2 ms·
I don't understand what the Basic example is supposed to do: var x, y, _this = this; a(b, function() { x = arguments[0], y = arguments[1]; return consol
by Kiro 13y ago
I don't understand what the Basic example is supposed to do:
var x, y,
_this = this;
a(b, function() {
x = arguments[0], y = arguments[1];
return console.log(x, y);
});
ReferenceError: a is not defined
- michaelmior 13y agoHere's a somewhat contrived example which I haven't tested, but I think illustrates the point although this particular case is probably better handled by other syntax presented later in the README. err, data = fs.readFile! path { if (err) throw err; console.log data }
- michaelmior 13y agoa is a function which would already be defined at this point. Anything after the exclamation point is arguments to the callback function. Any following code is wrapped in an anonymous function passed as the final argument to the function a. Anything on the left-hand side of the assignment (in this case, x and y) are arguments passed to this anonymous function. A concrete example of why you would do this would probably be useful.