Home >Web Front-end >Front-end Q&A >What is the difference between node.js and javascript

What is the difference between node.js and javascript

青灯夜游
青灯夜游Original
2021-10-19 14:18:3811743browse

Difference: 1. JavaScript is a scripting language, and Node.js is a development platform that allows JavaScript to run on the server; 2. JS prefers front-end browsers, and node prefers back-end; 3. JS The top-level object is the window object, and the top-level object in node is the global object.

What is the difference between node.js and javascript

The operating environment of this tutorial: windows7 system, javascript1.8.5&&nodejs version 12.19.0, Dell G3 computer.

JavaScript is an advanced, interpreted, literal scripting language. It is a prototype-based, function-first scripting language. It has been widely used in Web application development and is often used to add various features to web pages. Such dynamic functions provide users with a smoother and more beautiful browsing effect.

Node.js is a JavaScript running environment based on the Chrome V8 engine. It is a development platform that allows JavaScript to run on the server side.

The difference between node.js and javascript:

1. JavaScript is a scripting language, and Node.js is a script that allows JavaScript to run Development platform on the server side.

2. Nodejs and JS are both 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.

3. Top-level objects are different

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.

In the window object, defining a global variable can be accessed through Window, but it cannot be accessed through the global object in node, such as:

var a=100;
console.log(global.a);

This method is output The result is:

undefined

For the above example, because the variables defined in node are objects in the module, not global variables, the result is undefined.

[Recommended learning: javascript advanced tutorial]

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

Statement:
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