InterviewSolution
| 1. |
What is Express.js? |
|
Answer» Express.js is a Node.js FRAMEWORK to develop the BACKEND APIs of web and mobile application. It is Open San NPM package and is generally INSTALLED after creating a Node.js application.
Node.js itself is a JavaScript framework and is mainly used to develop backend APIs. But it can be used in SOCKET programming to create chat apps. In fact, Node.js can even be used without Express.js to create backend APIs. But the code is very complicated and more difficult to implement. This is where Express.js shines and does the ONE job perfectly for which it was created, which is, creating API endpoints. It adds the functionality of middleware and routing with ease in a Node.js application. Some difference between Express.js and Node.js are -
In this instance, we will write the same app in Express.js and Node.js. First, we will write the app in Node.js. Here, we are using the createServer() method and are writing the response in a template language. Now, we can go to http://localhost:3000/ and see the output. Next, we will create the same app in Express.js and see the difference. We don’t need the template code for the entire page. Besides this, the code is much cleaner and easier to understand. We can go to http://localhost:8080/ and we can see the result. |
|