Home  >  Article  >  Web Front-end  >  Is javascript a server-side scripting language?

Is javascript a server-side scripting language?

WBOY
WBOYOriginal
2022-06-29 16:52:372769browse

JavaScript is not a server-side scripting language, but a client-side scripting language; JavaScript is a scripting language whose source code does not need to be compiled before being sent to the client for running, and does not require server-side support. It is an interpretation A scripting language; nodejs can be used to achieve the effect of JavaScript running on the server side.

Is javascript a server-side scripting language?

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

Is javascript a server-side scripting language?

Javascript is not a server-side scripting language. JavaScript is a client-side scripting language. It does not require server support. It is an interpreted scripting language and is mainly used for applications. on the client side.

JavaScript is a scripting language. Its source code does not need to be compiled before being sent to the client for execution. Instead, the character code in text format is sent to the browser for interpretation and execution by the browser.

JavaScript script language has the following characteristics:

(1) Script language.

JavaScript is an interpreted scripting language. Languages ​​such as C and C are compiled first and then executed, while JavaScript is interpreted line by line during the running of the program.

(2) Based on objects.

JavaScript is an object-based scripting language that can not only create objects, but also use existing objects.

(3)Simple.

The JavaScript language uses weakly typed variable types and does not impose strict requirements on the data types used. It is a scripting language based on Java's basic statements and controls, and its design is simple and compact.

(4)Dynamic.

JavaScript is an event-driven scripting language that can respond to user input without going through the Web server. When visiting a web page, JavaScript can directly respond to these events when the mouse is clicked, moved up or down, or moved in the window.

(5) Cross-platform.

JavaScript script language does not depend on the operating system and only requires browser support. Therefore, after writing a JavaScript script, it can be brought to any machine for use, provided that the browser on the machine supports the JavaScript scripting language. Currently, JavaScript is supported by most browsers. [3]

Unlike server-side scripting languages, such as PHP and ASP, JavaScript is mainly used as a client-side scripting language to run on the user's browser and does not require server support. Therefore, in the early days, programmers preferred JavaScript to reduce the burden on the server, but at the same time it also brought about another problem: security.

As servers become more powerful, although programmers prefer scripts running on the server to ensure security, JavaScript is still popular for its cross-platform and easy-to-use advantages. At the same time, some special functions (such as AJAX) must rely on Javascript to be supported on the client side. With the development of engines such as V8 and frameworks such as Node.js, and their features such as event-driven and asynchronous IO, JavaScript is gradually used to write server-side programs.

Expand knowledge:

JavaScript script language programming example

JavaScript is a scripting language whose source code is developed It does not need to be compiled before running on the client. Instead, the character code in text format is sent to the browser for interpretation and execution by the browser. The weakness of literal translation languages ​​is that they are less secure, and in JavaScript, if one cannot run, then the following languages ​​cannot run either. The solution is to use try{}catch(){}:

console.log("a");//这是正确的
console.log("b");//这是正确的
console.logg("c");//这是错误的,并且到这里会停下来
console.log("d");//这是正确的
console.log("e");//这是正确的
/*解决办法*/
try{console.log("a");}catch(e){}//这是正确的`
try{console.log("b");}catch(e){}//这是正确的
try{console.logg("c");}catch(e){}//这是错误的,但是到这里不会停下来,而是跳过
try{console.log("d");}catch(e){}//这是正确的
try{console.log("e");}catch(e){}//这是正确的

Javascript is classified as a literal translation language, because mainstream engines load the code and interpret it every time it is run. V8 interprets all the code before starting to run it, while other engines interpret it line by line (SpiderMonkey will temporarily store the interpreted instructions to improve performance, which is called real-time compilation). However, because the core parts of V8 are mostly It is written in Javascript (and SpiderMonkey is written in C), so in different tests, the performance of the two has advantages and disadvantages. Corresponding to it is a compiled language, such as C language. Before a program written in a compiled language can be run, it must be compiled to compile the code into machine code and then run.

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

The above is the detailed content of Is javascript a server-side scripting language?. 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