node. js

Source: Internet
Author: User


I. Variable pollution
The global variables and functions in JS are overwritten

Two. node. JS Specification

Node application is made up of modules, using the COMMONJS module specification

Three. COMMONJS specification

1. Each file is a module with its own scope, defined in this file is private, other files are not visible
2. Use the Require method to load other modules
3. Within each module there is a module variable, which is an object whose exports attribute is the only interface to the external (module.exports)

Four. Commonjs Module features

1. All code runs at the module scope and does not pollute the global scope
2. The module can be loaded multiple times, but only run once at the first load, then run the result is cached, and then load, directly read the cache results, to let the module run again, it must be clearly cached
3. The order in which the modules are loaded, in the order in which they appear in the code

Five. Req/res in the route

Request: Requests (This object has all the data for this request)
Response: Response (This object can respond to the browser)
Res.send () responds some data (string/object) to the browser
Req.body getting the parameters of the POST request
Res.redirect () redirect Browser Web page (lets browser jump)

node. js

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.