node

Posted heidekeyi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了node相关的知识,希望对你有一定的参考价值。

 

 

1 全局对象

  • global
console.log(global);

// Object [global] 
//     global: [Circular],
//         clearInterval: [Function: clearInterval],
//     clearTimeout: [Function: clearTimeout],
//     setInterval: [Function: setInterval],
//     setTimeout: [Function: setTimeout]  [Symbol(util.promisify.custom)]: [Function] ,
//     queueMicrotask: [Function: queueMicrotask],
//     clearImmediate: [Function: clearImmediate],
//     setImmediate: [Function: setImmediate] 
//         [Symbol(util.promisify.custom)]: [Function]
//     
// 
  • console
console.log(console)

// 
//     log: [Function: bound consoleCall],
//     warn: [Function: bound consoleCall],
//     dir: [Function: bound consoleCall],
//     time: [Function: bound consoleCall],
//     timeEnd: [Function: bound consoleCall],
//     timeLog: [Function: bound consoleCall],
//     trace: [Function: bound consoleCall],
//     assert: [Function: bound consoleCall],
//     clear: [Function: bound consoleCall],
//     count: [Function: bound consoleCall],
//     countReset: [Function: bound consoleCall],
//     group: [Function: bound consoleCall],
//     groupEnd: [Function: bound consoleCall],
//     table: [Function: bound consoleCall],
//     debug: [Function: bound consoleCall],
//     info: [Function: bound consoleCall],
//     dirxml: [Function: bound consoleCall],
//     error: [Function: bound consoleCall],
//     groupCollapsed: [Function: bound consoleCall],
//     Console: [Function: Console],
//     profile: [Function: profile],
//     profileEnd: [Function: profileEnd],
//     timeStamp: [Function: timeStamp],
//     context: [Function: context],
//     [Symbol(kBindStreamsEager)]: [Function: bound ],
//     [Symbol(kBindStreamsLazy)]: [Function: bound ],
//     [Symbol(kBindProperties)]: [Function: bound ],
//     [Symbol(kWriteToConsole)]: [Function: bound ],
//     [Symbol(kGetInspectOptions)]: [Function: bound ],
//     [Symbol(kFormatForStdout)]: [Function: bound ],
//     [Symbol(kFormatForStderr)]: [Function: bound ]
// 

  • exports, require, module, _filename, _dirname(模块参数)
console.log(arguments.callee + ‘‘);

// function (exports, require, module, __filename, __dirname) 
//     console.log(arguments.callee + ‘‘);

2 代码执行优先级

同步代码优先,例子如下

// 代码执行优先级
setTimeout(function () 
    setTimeout(function () 
        console.log(‘time out‘);
    , 0);
    new Promise(resolve => 
        setTimeout(function () 
            console.log(‘start in Promise‘);
        , 1);
        console.log(‘beg‘);
        resolve();
        console.log(‘end‘);
        setTimeout(function () 
            console.log(‘end in Promise‘);
        , 0);
    ).then(() => 
        console.log(‘finish‘);
    );
    console.log(‘不要调皮‘);
, 100);

// beg
// end
// 不要调皮
// finish
// time out
// start in Promise
// end in Promise

Created: 2019-06-23 周日 23:42

 

 

 

 

#+LATEX_HEADER: \usepackagectex

* 全局对象
- global
:g:
#+BEGIN_SRC javascript
  console.log(global);

  // Object [global] 
  //     global: [Circular],
  //         clearInterval: [Function: clearInterval],
  //     clearTimeout: [Function: clearTimeout],
  //     setInterval: [Function: setInterval],
  //     setTimeout: [Function: setTimeout]  [Symbol(util.promisify.custom)]: [Function] ,
  //     queueMicrotask: [Function: queueMicrotask],
  //     clearImmediate: [Function: clearImmediate],
  //     setImmediate: [Function: setImmediate] 
  //         [Symbol(util.promisify.custom)]: [Function]
  //     
  // 
#+END_SRC
:END:

- console
:g:
#+BEGIN_SRC javascript
  console.log(console)

  // 
  //     log: [Function: bound consoleCall],
  //     warn: [Function: bound consoleCall],
  //     dir: [Function: bound consoleCall],
  //     time: [Function: bound consoleCall],
  //     timeEnd: [Function: bound consoleCall],
  //     timeLog: [Function: bound consoleCall],
  //     trace: [Function: bound consoleCall],
  //     assert: [Function: bound consoleCall],
  //     clear: [Function: bound consoleCall],
  //     count: [Function: bound consoleCall],
  //     countReset: [Function: bound consoleCall],
  //     group: [Function: bound consoleCall],
  //     groupEnd: [Function: bound consoleCall],
  //     table: [Function: bound consoleCall],
  //     debug: [Function: bound consoleCall],
  //     info: [Function: bound consoleCall],
  //     dirxml: [Function: bound consoleCall],
  //     error: [Function: bound consoleCall],
  //     groupCollapsed: [Function: bound consoleCall],
  //     Console: [Function: Console],
  //     profile: [Function: profile],
  //     profileEnd: [Function: profileEnd],
  //     timeStamp: [Function: timeStamp],
  //     context: [Function: context],
  //     [Symbol(kBindStreamsEager)]: [Function: bound ],
  //     [Symbol(kBindStreamsLazy)]: [Function: bound ],
  //     [Symbol(kBindProperties)]: [Function: bound ],
  //     [Symbol(kWriteToConsole)]: [Function: bound ],
  //     [Symbol(kGetInspectOptions)]: [Function: bound ],
  //     [Symbol(kFormatForStdout)]: [Function: bound ],
  //     [Symbol(kFormatForStderr)]: [Function: bound ]
  // 

#+END_SRC
:END:

- exports, require, module, __filename, __dirname(模块参数)
:g:
#+BEGIN_SRC javascript
  console.log(arguments.callee + ‘‘);

  // function (exports, require, module, __filename, __dirname) 
  //     console.log(arguments.callee + ‘‘);
#+END_SRC
:END:
* 代码执行优先级
同步代码优先,例子如下
:g:
#+BEGIN_SRC javascript
  // 代码执行优先级
  setTimeout(function () 
      setTimeout(function () 
      console.log(‘time out‘);
      , 0);
      new Promise(resolve => 
      setTimeout(function () 
          console.log(‘start in Promise‘);
      , 1);
      console.log(‘beg‘);
      resolve();
      console.log(‘end‘);
      setTimeout(function () 
          console.log(‘end in Promise‘);
      , 0);
      ).then(() => 
      console.log(‘finish‘);
      );
      console.log(‘不要调皮‘);
  , 100);

  // beg
  // end
  // 不要调皮
  // finish
  // time out
  // start in Promise
  // end in Promise
#+END_SRC
:END:

 

以上是关于node的主要内容,如果未能解决你的问题,请参考以下文章

关于 Nodenode-sass 版本不匹配导致的 Vue 项目装包报错的问题

代码测试

树的遍历

leetcode590

递归方式遍历二叉树:

判断两个单链表是否相交