Know nodeJS? What are the differences and commonalities with Web js?

This question tests the interviewer’s knowledge of NodeJS and the JS standard.

In common

ECMAScript 8 (ES2017)

This syntax includes variable definitions, loops, judgments, functions, stereotypes, prototype chains, scopes, closures, asynchron, etc. ECMAScript only defines syntax, but it cannot manipulate DOM, listen for click events, send Ajax requests, process HTTP requests, manipulate and read files, Can’t access the database, only it, can hardly do any actual projects. So nodeJS and web standard JS both extend it functionally.

The difference between

nodeJs

NodeJs mainly runs on the server side, and can do file reading and writing, database connection, network connection and other operations. Moreover, there is no compatibility problem, because the running kernel is the same kernel V8 engine. NodeJs also has some built-in variables (__dirname, etc.) and a built-in nodeApi. It functions like the Java language and is used as a back-end service. Node also has popular frameworks like Java express, KOA, etc.

Standard js

Standard JS usually runs on a browser, so it contains standard syntax and DOM and BOM. Dom mainly describes the methods and interfaces for processing web content. The whole document is parsed into A DOM tree for users to process the document with JS. BOM describes the methods and interfaces (object structure) that can interact with the browser window, such as: Window objects, history, location, Navigator, etc., have great compatibility problems due to different browser kernels and versions. Simple understanding is that the ECMAScript version is updated all the time, but the user browser and kernel version may not keep up, so front-end programmers have to face compatibility problems. The mainstream approach is to use Babel to escape syntax, as you can see in my other article on Babel installation.

conclusion

It can be seen that Node and webJs have the same syntax, so front-end JS developers can easily learn NodeJS. Nodejs is mainly used for server construction, while webJs is mainly run in the client browser, helping users to complete interactive operations, rendering pages, etc.

Personal blog: Visit

Learning is like rowing upstream, not to advance is to fall back, the rapid development of front-end technology, if you don’t keep learning every day, you will not keep up, I will accompany you, every day to push blog, progress with you, I hope you can pay attention to me, the first time to receive the latest article.

The public no. :