What is “server” in server-side javascript like NodeJS?

允我心安 提交于 2021-02-04 10:21:06

问题


Is it not a Javascript engine hosted by the browser on the client machine itself?


回答1:


No, it isn't.

Server generally has two meanings:

  1. A piece of software that listens for network requests and then responds to them
  2. A computer running such a piece of software

A Node.JS server can be either of those.

In web programming, a Node.JS server takes the place of Perl, Python, Ruby, PHP, Scala, etc. (And like those other languages, Node.JS lets you use JavaScript for non-server and non-web purposes).

Generally the server itself is run directly from Node (e.g. with this library) rather than being embedded in another server like Apache (as is most common for PHP).

A browser doesn't need to be involved at all. If one is, then it will probably be one acting as a client and making a request to the server. That said, tools like PhantomJS can allow a browser to be driven from Node (and other programming languages).




回答2:


From here:

Server-side JavaScript (SSJS) refers to JavaScript that runs on server-side and is therefore not downloaded to the browser. This term is used to differentiate it from regular JavaScript, which is predominantly used on the client-side (also referred to as client-side JavaScript or CSJS for short).




回答3:


NodeJS runs on the V8 JavaScript Engine which does not have to be in a browser. It just executes JS. It does not depend on what you do with it. In the case of a NodeJS server, it listens to HTTP requests and is therefore a server.




回答4:


node.js is single threaded process and run event loops




回答5:


Node.js is a framework/program that is installed on a machine and contains code written in javascript and process those codes requested by a client like a browser, Yes each browser contains its own engine that process the javascript.



来源:https://stackoverflow.com/questions/34511505/what-is-server-in-server-side-javascript-like-nodejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!