Looks like you run an adblocker app in your browser!
We all hate ads. But ads power most of the web services you use on a daily basis. This message is an appeal to you to disable your ad-blocking app on services you use frequently to support the owner. Cheers!
Node.js is a Server side scripting which is used to build scalable programs. Its multiple advantages over other server side languages, the prominent being non-blocking I/O.
a highly scalable system that uses asynchronous, event-driven I/O (input/output),
rather than threads or separate processes. It’s ideal for web applications that are frequently accessed but computationally simple.
If you’re using a traditional web server, such as Apache, each time a web resource is
requested, Apache creates a separate thread or invokes a new process in order to handle
the request. Even though Apache responds quickly to requests, and cleans up after the
request has been satisfied, this approach can still tie up a lot of resources. A popular
web application is going to have serious performance issues.
Node, on the other hand, doesn’t create a new thread or process for every request.
Instead, it listens for specific events, and when the event happens, responds accordingly. Node doesn’t block any other request while waiting for the event functionality
to complete, and events are handled—first come, first served—in a relatively uncomplicated event loop.
Node can be installed in a Unix/Linux, Mac OS, or Windows environment. This chapter will walk you through setting up a development environment for Node in Windows
7 and Linux (Ubuntu). Installation on a Mac should be similar to installation on Linux.
I’ll also cover any requirements or preparation you need to take before installing the
Once your development environment is operational, I’ll demonstrate a basic Node
application and walk you through the important bit—the event loop I mentioned
2. How node.js works
3. What do you mean by the term I/O ?
I/O is the shorthand for input and output, and it will access anything outside of your application. It will be loaded into the machine memory to run the program, once the application is started.
4. What does event-driven programming mean?
In computer programming, event driven programming is a programming paradigm in which the flow of the program is determined by events like messages from other programs or threads.
5. Where can we use node.js?
Node.js shines in real-time web applications employing push technology over web sockets. It can be used for the following purposes:
a) Web applications (especially real-time web apps)
b) Network applications
c) Distributed systems
d) General purpose applications
6. What is the advantage of using node.js?
It provides an easy way to build scalable network programs
a) Easy to install and run locally
b) Generally fast
c) Great concurrency
d) Asynchronous everything
e) Almost never blocks
f) Unified programming language and data type
7. What are the two types of API functions in Node.js?
The two types of API functions in Node.js are:
a) Asynchronous, non-blocking functions
b) Synchronous, blocking functions
8. What is control flow function?
A generic piece of code which runs in between several asynchronous function calls is known as control flow function.
9. Explain the steps how “Control Flow” controls the functions calls?
Control the order of execution -> Collect data -> Limit concurrency -> Call the next step in program
10. Why Node.js is single threaded?
For async processing, Node.js was created explicitly as an experiment. It is believed that more performance and scalability can be achieved by doing async processing on a single thread under typical web loads than the typical thread based implementation.
11. Does node run on windows?
Incorrect. The correct answer is :
12. Can you access DOM in node?
No, you cannot access DOM in node.
13. Using the event loop what are the tasks that should be done asynchronously?
a. I/O operations
b. Heavy computation
c. Anything requiring blocking
14. Why node.js is quickly gaining attention from JAVA programmers?
15. What are the two arguments that async.queue takes?
The two arguments that async.queue takes
a) Task function
b) Concurrency value
16. What is an event loop in Node.js ?
To process and handle external events and to convert them into callback invocations an event loop is used. So, at I/O calls, node.js can switch from one request to another .
17. Mention the steps by which you can async in Node.js?
By following steps you can async Node.js :
First class functions -> Function composition -> Callback Counters -> Event loops
18. What are the pros and cons of Node.js?
b) Crawlers receive a full-rendered HTML response, which is far more SEO friendly rather than a single page application or a websockets app run on top of Node.js.
a) Any intensive CPU computation will block node.js responsiveness, so a threaded platform is a better approach.
b) Using relational database with Node.js is considered less favorable.
19. How Node.js overcomes the problem of blocking of I/O operations?
Node.js solves this problem by putting the event based model at its core, using an event loop instead of threads.
20. What is the difference between Node.js vs Ajax?