Home > Web Front-end > Front-end Q&A > Can javascript only run in the browser?

Can javascript only run in the browser?

WBOY
Release: 2022-07-01 15:43:36
Original
3490 people have browsed it

JavaScript can not only run in the browser, but can also run in the "Node.js" environment; the "Node.js" running environment uses ECMAScript as the basis to extend "I/O" operations, File operations, database operations, etc. enable JavaScript to run on the server side as a server-side scripting language.

Can javascript only run in the browser?

The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.

Can JavaScript only run in the browser?

No, JavaScript can not only run in the browser, but can also run in other operating environments, such as node. js environment.

1. JavaScript is designated as a browser scripting language. Its running environment has always been the client browser, because the original intention of JavaScript design is to do some interaction between the browser and the user. Some web page special effects complement the deficiencies of html and css.

2. In 2009, a technology called node.js was born. Node.js is a Javascript runtime environment (runtime). In fact, it encapsulates the Google V8 engine. Node.js is a platform based on the Chrome JavaScript runtime, which is used to easily build web applications with fast response speed and easy expansion. Node.js enables JavaScript to run on the server side as a server scripting language, similar to dynamic languages ​​such as PHP.

3. Therefore, there are currently two running environments for JavaScript: browser and node.js environment.

JavaScript has two running environments:

  • One is the browser running environment

  • One It is the Node.js running environment

Node.js is based on ECMAScript and extends I/O operations, file operations, database operations, etc.

JavaScript is defined as a browser scripting language. Its running environment has always been the client browser, because the original intention of JavaScript design is to do some interaction between the browser and the user and some special effects on the web page. Complement the deficiencies of HTML and CSS.

In 2009, node.js technology was born. node.js is a Javascript runtime environment (runtime). In fact, it encapsulates the Google V8 engine. Node.js is a platform based on the Chrome JavaScript runtime, which is used to easily build web applications with fast response speed and easy expansion.

node.js enables JavaScript to run on the server side as a server scripting language, similar to dynamic languages ​​such as php.

Extended knowledge:

Simply put, Node.js is JavaScript running on the server side.

Node.js is a platform built on the Chrome JavaScript runtime.

Node.js is an event-driven I/O server-side JavaScript environment based on Google's V8 engine. The V8 engine executes Javascript very quickly and has very good performance.

Script mode

Example

console.log("Hello World");
Copy after login

Save the file with the file name helloworld.js and execute it through the node command:

node helloworld.js
Copy after login

After the program is executed, if it is normal, Hello World will be output in the terminal.

Interactive mode

Open the terminal and type node to enter the command interactive mode. You can enter a code statement and execute it immediately and display the result, for example:

$ node
> console.log('Hello World!');
Hello World!
Copy after login

[Related recommendations: javascript video tutorial, web front-end

The above is the detailed content of Can javascript only run in the browser?. 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