Node. JS Series notes 4-(not updated regularly)

Source: Internet
Author: User

  • node. JS Global Object
    • Special objects in JavaScript: Global objects, Universal object
    • It and all its properties can be accessed from anywhere in the program
    • In browser JavaScript, typically window is a global object, and node. JS is global, and all global variables (except global itself) are properties of the global object
    • ECMAScript definition, global variables include
      • Variables defined at the outermost layer
      • Properties of global objects
      • Implicitly defined variables (no direct assignment defined)
    • When defining a global variable, this variable becomes a property of the global object and vice versa
    • It is not possible to define variables at the outermost layer in node. js because all user code belongs to the current module and the module itself is not at the outermost
    • Note It is best to always use Var to define variables to avoid introducing global variables, which pollute namespaces and increase the risk of code coupling
  • __filename
    • Console.log (__filename);
    • Output the file name of the currently executing script, output absolute path
    • If the module file path is output in the module
  • __dirname
    • Console.log (__dirname);
    • The directory where the output execution script resides
  • SetTimeout (CB, MS)
    • The global function, which executes the specified function CB after the specified number of milliseconds, executes only once
    • Note that the program does not stop at this statement, but will continue
  • Cleartimeout (t)
    • Used to stop a timer that was previously created by SetTimeout ()
    • 1 var t = setTimeout (Printhello, +); 2 cleartimeout (t);
  • Console
    • Console is used to provide console standard output, which is a debugging tool provided by IE's JScript engine, and later becomes the de facto standard of the browser.
    • node. JS uses this standard to stderr output characters to standard output stream stdout and standard error streams
    • Console method
      • Links: http://www.runoob.com/nodejs/nodejs-global-object.html
  • Process
    • Process is a global variable, that is, the properties of the global object
    • An object that describes the state of the current node. JS process and provides a simple interface to communicate with the operating system
    • Event: Exit/beforeexit/uncaughtexcepiton/signal
    • Exit Status:
    • Property: Stdout/stderr/stdin/argv/execpath/env/exitcode/version/pid/platform
    • Method Reference Manual:
    • Links: http://www.runoob.com/nodejs/nodejs-global-object.html

Node. JS Series notes 4-(not updated regularly)

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.