3 ms·
Little nitpick: Why make the draw event handler a magic variable instead of a function which takes a function? Ie: var draw = function() { point(random(0,
by rabidsnail 14y ago
Little nitpick: Why make the draw event handler a magic variable instead of a function which takes a function?
Ie:
var draw = function() { point(random(0, 400), random(0, 400)); };
as opposed to
onDraw(function() { point(random(0, 400), random(0, 400)); });
AFAICT there aren't any other variables that side-effect based on what you've assigned to them.
- phleet 14y agoGranted this is certainly not JS best practices, but following best practices was not our goal here. Explaining variable assignment is much simple than explaining callbacks and/or higher order functions. On a more practical note, this is the convention that processing.js uses, and thats what we're using to render the canvas.
- pbreit 14y agoThe former is much easier to understand.