nielsdoorn/nodejsworkshop — pull request #2 by basti1302 (2014-01-17 07:55:48+00:00)
Title: Fix function call instead function reference error

There was an example for callback style that read like this:

var myCallback = function(result) {
doSomethingWithTheResult(result);
}
db.query("SELECT * FROM largeTable", myCallback(result));

Which will not work, unless `doSomethingWithTheResult(result)` returns a *function* that works with the result. This is probably not what has been intended. The only correct way to do this is by using a function reference to myCallback:

db.query("SELECT * FROM largeTable", myCallback);

Since this is an important concept in Node I felt the need to fix it to not confuse our aspiring Node newbies. I left the flawed example in there with a warning clearly indicating that this is not the right way to do it because function call versus function reference is often a source of confusion.