In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces what Node refers to in web. It is very detailed and has certain reference value. Friends who are interested must finish reading it.
Node.js is the JavaScript that runs on the server, and it is also a platform based on the Chrome JavaScript runtime.
1. Write a javascript toolkit for a high-performance network server (develop server programs with js)
two。 Single threaded, asynchronous, event driven
Single threading: 01.php does not support multithreading, but php's service apache supports multithreading, which initializes 150threads for use by php at startup. In the thread pool, the thread work provides the content to the client and then goes back to the thread pool to wait for being called; 02.node.js single-thread, multiple threads operate on the library, each thread corresponds to a block of memory; how to deal with high concurrency and large amount of data in 03.PHP? Let the thread end quickly (thread optimization, primary key)
Asynchronous and event-driven: perform other operations after asynchronously accessing the database. The access process is very fast, and an error will be reported when the data is needed in the next step, so you need to put the next operation into the above function and use it as a callback function. There are asyac methods in node.js to make programs execute sequentially.
3. Features: use event-driven, non-blocking IO model (asynchronous to put it simply), lightweight and efficient
4.node.js vs php
Advantages:
01. High performance
02. High development efficiency (less amount of optimization)
03. Wide range of applications (can develop desktop systems: electorn framework)
Disadvantages:
01. New and few people
02. Few middleware
03.IDE is not perfect.
5.node request static server
Var http=require ("http"); / / http is an object included in node, which is imported using require
Http.createServer (function (request,response) {
Response.writeHead (200,{ "Content-Type": "text/html;charset=utf-8"})
Console.log ("access")
Response.write ("hello world")
Response.end ("Hello, World!")
}) .customers (8000)
Console.log ("Server running at http://127.0.0.1:8000/");"
6.node Modular Development and commonJS Specification
(1) Module reference
Exports.add=function (num1,num2) {
Alert (num1+num2)
} / / the interface provided by the module, which is assumed to be stored in add.js
Var obj=require (". / add.js"); / / Module reference
The significance of the assignment is that only obj will be recognized in js because it is a defined variable and cannot be recognized as. / add.js
Obj.add (3d5); / / correct calling method
(2) Module definition
Module object: in each module, the module object represents the module itself.
Export property: a property of the module object that provides an interface to the outside.
(3) Module identification
Module identification refers to the parameters passed to the require method, which must be a string named in accordance with the small hump, or. Or; or The relative path at the beginning, or the absolute path.
The above is all the content of the article "what does Node in web mean?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.