Share On Twitter Facebook Google+ LinkedIn Pinterest Tumblr Reddit
Question

Can node js be used for front end?

Tags: frontend node.js
Date:
Status:Unresolved
Question Id:36

I have heard about Node.js being used in the frontend side of the application as opposed to the backend side, but I cannot find any use cases for which it can be used. Can somebody explain the use cases for which Node.js is used in the frontend.

Answer
Date:
Correct:No

Node.js is a javascript runtime that uses the Chrome V8 javascript engine. The front-end already uses a javascript engine on the browser (V8 for Chrome, SpiderMonkey for Firefox, Chakra for Edge), so whether Javascript is running in the browser on in Node.js, you can expect very similar environments.

However, you might be interested in using Node.js modules on the front-end. The modules are packaged using a tool called npm. You can use module loaders or bundlers like Browserifywebpack, or Rollup.js to accomplish this.

Answer
Date:
Correct:No

Node.js is essentially a runtime environment based on the V8 Javascript engine for Chrome, which means it can Javascript out of the execution context of a browser.

To draw a very vague analogy Node.js is to Javascript is what JRE is to Java,(not a very proper comparison though)

It depends upon you as to how you would want to leverage Node.js.

Since it can run Javascript outside of the context of a browser and also has capabilities to run a non-blocking I/O based HTTP Server (with the help of http libraries) which it provides out-of-the-box, you can use it at the back-end/server side scenarios.

Also you can use Node.js in the front end so as to automate your daily tasks such build , running unit tests of your front end code. Tools like Grunt , Gulp , Bower leverage capabilities of Node.js so as to improve and enhance your software development.

Also presently Angular 2 is also using Node.js for installing packages and compilation of Typescript to Javascript.

Hence , the conclusion is Node.js in practice can be used in both front-end and back-end scenarios, but in essence was developed to serve the purpose where Javascript can be used in the server side for development of web applications, thus leading to having a single language for both front end and backend development

Hope this helps.

Answer
Date:
Correct:No

Node.js is a runtime environment. That’s far broader than “backend” or “frontend”, which is an important distinction when understanding how to use it.

Backend/frontend refers to a client/server programming model (which is not just web!). There are others. For example, you can execute a program from a terminal (CLI, i.e. command line interface). You can run a program as a background daemon. You can build desktop software with Node (Electron, NW.js, etc). Those are all different envrionments. You can even run programs to build code for other environments.

Node.js can be used almost anywhere except in the browser. It doesn’t exist in the browser, and for good reason… it’s a JavaScript runtime, which already exists in browsers. Node can be used for traditional backend purposes, such as serving web pages or acting as an API. However; most people don’t realize this is not the most common use of Node.

Node is most frequently used to create command line utilities and build processes. For example, npm is a command line utility for Node. So is Webpack, Babel, most React tools, and many other popular developer build tools. 97% of modern web browser code is maintained in the npm registry, which makes Node/npm a critical part of the development environment for writing code which targets the browser.

It’s also important to note that the “frontend” isn’t always a web page. A user interface can be a terminal screen… it doesn’t have to be a browser. In those situations, Node can be of value for “frontend” and even “UI” development.

The main point here is backend/frontend are loosely defined concepts. Most people use them to describe web programming, but there are several other contexts to consider. In a broader context, Node is applicable in most environments.

Answer
Date:
Correct:No

Node.js is a runtime environment, which let users choose how to use, whether frontend or backend, and one common language can be used as backend and front end.

This environment is entirely based on V8 JavaScript engine.

As this environment provides feature of easily executing JavaScript document which are not even executed in web browser so can be used as Backend environment, whereas it also have feature to automate routine task which include executing testing of code, tool kit, etc. so you can even use it as front –end environment, which will enhance development of software.

In short, it can be used for both! Hope this makes things clear! Do follow back for further queries!

Your Answer

Review Your Answer