Recently, I began studying JavaScript, and I reached a topic about asynchronous coding, or some refer to it as function parameter or callback (node.js to be more specific).
I tested some stuff with it, but can`t get the idea of it. For example
window.addEventListener("click", function(){ alert("HELO"); }, true);
will do nothing. Can somebody explain in short what exactly is the idea behind asynchronous coding and what are these callbacks, also a 3-4 line example will be appreciated.
-
Check out a tutorial, there are bunch of them!KARASZI István– KARASZI István2012年01月14日 09:29:35 +00:00Commented Jan 14, 2012 at 9:29
-
1question is too broad in scopeLloyd– Lloyd2012年01月14日 09:40:34 +00:00Commented Jan 14, 2012 at 9:40
-
@nalply Like Carl said in his answer, the window object is not part of the node.js environment. You are executing that code in Chrome which has the window object.abelito– abelito2012年01月14日 09:57:52 +00:00Commented Jan 14, 2012 at 9:57
-
duh, didn't see that the question was about node.jsnalply– nalply2012年01月14日 18:26:36 +00:00Commented Jan 14, 2012 at 18:26
1 Answer 1
The code you have written requires the window object which is not a part of the node.js environment.
I recommend watching ryan dahl's introduction to node.js
4 Comments
ve found that book and I think that this book http://www.amazon.com/gp/product/1593272820?ie=UTF8&tag=marijhaver-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=1593272820 is good for JS too with Crockfords.