Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

When I use jquery library I notice that the code will continue execution regardless the previous line complete the execution. More precisely while using jquery ajax, it will continue execution without waiting for the ajax result. Is this because javascript takes advantage of parallel processing? Or to which category this can be referred to. Also can we call javascript as a functional programming language.? It will be greatly appreciated if someone could explain this briefly. Thanks in advance.

share|improve this question
add comment

2 Answers 2

Here is the deal.

1) You can use JavaScript as a functional language. I do so every day! its a great way to write code in JavaScript. The array operations in recent versions of JavaScript and the fact that the JavaScript function has all the power of a lambda in other languages make this easy to do. I would not call JavaScript a functional language but would call it a multi para-dime language.

2) There is only one thread of operation in JavaScript, however many things including Ajax operate in an Asynchronous manor. So when you make an Ajax call it returns right away and when server returns a value it sends an event that contains the return value.

3) JavaScript also lets you plan events for some time in the future. So you can tell it "In 500ms run this function"

There is a chapter on functional javascript in Programming HTML5 Applications this will be out in August. There should be a preview version of the book out sooner.

share|improve this answer
    
Book looks interesting, I've preordered it on Amazon. Where do I get the preview? It's not that I'm impatient, but I want everything NOW!! ;) –  Ian Apr 17 '11 at 9:49
    
Thank you, I hope it is interesting –  Zachary K Apr 17 '11 at 9:55
add comment

No, ajax does not make use of parallel processing.

The A in ajax stands for asynchronous. This means that it sends off a request to the server, and then continues on processing the next statement. When the ajax data is ready, that code executes.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.