node. JS Learning Note One

Source: Internet
Author: User

node. jsnode is a platform and a language. It is a platform or running environment, can let JS run on the server side, because it encapsulates the V8 engine (engine, the ability to parse the JS code into a computer can understand the language), can let JS run on other platforms, and not just run on the browser. It is a server-side language, similar to Php,java. JS is an explanatory language, not compiled, the computer does not recognize, so Google V8 engine compiled JS code. callback functionFunction A has a parameter b,b is a function that executes B when function a finishes. Function B is passed to function a in the form of a parameter. node. JS features(Single-threaded, asynchronous, non-blocking) (instantaneous throughput is very large) asynchronous, non-blocking: blocking (a request must be executed to execute the second request), non-blocking (a callback is executed once a request has been made.) Multiple requests are made, and several callbacks are executed). Single threaded: One core inside runs multi-threaded: One core runs multiple tasks, and a process has a lot of threads. ModuleFile and module one by one corresponding, a file is a module, exposed to a number of external module.exports, exposed to a exports JS single-threaded and asynchronousSingle-threaded and asynchronous does not have to be a language feature at the same time. JS chose to become a single-threaded language, so it can not be asynchronous, but JS hosting environment (such as browser, Node) is multi-threaded, the host environment in some way (event-driven) to make JS with the asynchronous properties. JS is a single-threaded language, the browser is only assigned to JS a main thread, and then for some more time-consuming tasks in addition to open up a thread, this line thread task is asynchronous. node. JS RoutingRespond differently to different requests, Try--catchPut the code in a try, and if the code inside does not have an error handling mechanism, the error is caught by the catch and the Catch method is executed. SummaryHttp:var http = require ("http"),//nodejs Load module method, HTTP system module dedicated to node creation service.     The introduction of HTTP module can realize LAN communication, create service, http://request, etc. Http.createserver (function () {})//create service Url:var URL = require (' URL '); Url.parse (Req.url); The URL module is introduced to convert the requested URL into an object.

node. JS Learning Note One

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.