Home > Web Front-end > JS Tutorial > What is the difference between js and node.js? Summary of similarities and differences between js and node.js

What is the difference between js and node.js? Summary of similarities and differences between js and node.js

寻∝梦
Release: 2018-09-05 16:09:23
Original
3497 people have browsed it

Do you know the difference between node.js and javascript? Do you know the similarities between node.js and javascript? If you don’t know, then come and read this article. What are you waiting for? Let’s read it now

1. Let’s first take a look at the comparison between js and node.js:

JavaScript:

ECMAScript (language basics, such as syntax, data type structure and some built-in objects)

DOM (some operation page elements Methods)

BOM (Some methods of operating the browser)

The above are the components of JavaScript, but what about Nodejs?

Nodejs:

ECMAScript (language basics, such as syntax, data type structures and some built-in objects)

os (operating system)

file(file system)

net(network system)

database(database)

Analysis: It is easy to see that the js of the front-end and back-end are the same That is, their language foundations are both ECMAScript, but the things they extend are different. The front end needs to operate page elements, so it extends the DOM, and it also needs to operate the browser, so it extends the BOM. The js on the server side is also based on ECMAScript and extends some APIs required by the server. Children who know a little about the background must know that the background voice has the ability of the operating system, so to expand os, you need to have the ability to operate files, so file is expanded. The file system needs to operate the network, so the net network system needs to be expanded, and the data needs to be operated, so the capabilities of the database need to be expanded.

After such a comparison, I believe many friends have a better understanding of nodejs. It turns out that the front-end and server-side js are so similar. Their foundations are the same, but the environments are different, which leads to different things they expand. (If you want to see more, go to the PHP Chinese website node.js video tutorial column to learn, you can also learn by watching the video)

2. Summary of similarities and differences between js and node.js:

Javascript composition: ecmascript (defines the basis of this language, such as syntax, data types, structures, and some built-in objects, etc.), DOM (based on ecmascript, extended methods for operating page elements) , BOM (based on ecmascript, extended methods for operating browsers).

nodejS is based on ECMASCRIPT, and then extended on this basis some methods to operate other things (that is, operate non-browsers), such as operating OS operating system, file file system, net network, database Database etc. In other words, nodejs and JS are the same at the bottom level, both are ecmascript, but the extended functions are different. One is biased towards front-end browsers, and the other is biased towards back-end.

In the ecmascript part, node and JS are actually the same, such as the definition of data types, syntax structures, and built-in objects. But the top-level object in js is the window object, but there is no window object in node. The top-level object in node is the global object. This is the difference between the two.

3. There are some differences that are easy to see:

  • JavaScript is a language

  • node.js is not a language, nor is it a special JavaScript dialect - it is just something used to run ordinary JavaScript code

  • All browsers run web pages JavaScript engine for JavaScript. Firefox has an engine called Spidermonkey, Safari has JavaScriptCore, and Chrome has V8

  • node.js is a V8 engine that can operate I/O and network libraries, so you can run it in the browser In addition, JavaScript is used to create shell scripts and background services or run on hardware

  • Javascript is a web front-end language, mainly used in web development, and is parsed and executed by the browser

  • Node.js is a platform that can quickly build network services and applications. It is a service platform built with Javascript language and can be used to build servers on the backend

They all use js syntax, the former is mainly used in front-end and the latter is mainly used in back-end

  • The difference between node.js and javascript is quite big, 1 platform, 1 platform Programming language;

  • javascript is a client-side programming language, which requires the browser's javascript interpreter for interpretation and execution;

  • node.js is a A platform built on the Chrome JavaScript runtime, it is a running environment that encapsulates the Google V8 engine;

  • Simply put, node.js encapsulates the browser's interpreter as The server running platform uses a JavaScript-like structural syntax for programming and runs on node.js.

The above is a summary of the differences, similarities and differences between node.js and js in this article (if you want to learn more, go to the node.js Chinese Reference Manual column on the PHP Chinese website ). The full text is easy to understand. If you have any questions, you can leave a message below.

【Editor’s Recommendation】

What are the advantages of node.js? An introduction to the advantages and disadvantages of node

What is node.js suitable for? What are the benefits of using node.js?

The above is the detailed content of What is the difference between js and node.js? Summary of similarities and differences between js and node.js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template