1

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.

4
  • Check out a tutorial, there are bunch of them! Commented Jan 14, 2012 at 9:29
  • 1
    question is too broad in scope Commented 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. Commented Jan 14, 2012 at 9:57
  • duh, didn't see that the question was about node.js Commented Jan 14, 2012 at 18:26

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

4 Comments

From the video, "node is basically a set of libraries on top of Google's V8 engine to create networking applications [written in javascript]". The video is very, very helpful.
Thanks for replying. JS is kind of new to me so my questions may still be lame :)
It's not a lame question. And if you wanna learn more about javascript I really recommend Douglas Crockfords book amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/…
Ive 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.