Node JS is a runtime environment built on Chrome’s V8 engine.
It is is very efficient in communication. Its great with WebSocket communication.
Write data validation only once( DRY Rule )
Because you can write your JS code both for front end and for the server, you can do the data validation only one.
How does Node work?
Node is not just a JavaScript engine. You can take the V8 engine compile it and run it on your server and you can even put some JS code in it and it will do that code. But what you cannot do with V8 is that you cannot see what it does.
JS engine does not have any concept of I/O.
So what node does is, it provides a hosting environment for that JavaScript. It extends the JS from its pure native sense into an environment that lets you do stuff with it like write to the screen or open up and read a file.
Please not that when you do console.log
in your browser, the browser and the developer tools have provided an I/O hook. that allows that console.log
to work.
Node does a similar thing. Node has taken the I/O ( Input Output stream ). Its given you a binding from its lower level C layer into the JS so that when we do console.log in node we can actually see something printing to the screen.