`
banxi1988
  • 浏览: 151943 次
  • 性别: Icon_minigender_1
  • 来自: 桂林
社区版块
存档分类
最新评论

nodejs全局对象

阅读更多
下面的东西基本是翻译自以下地址:
http://nodejs.org/docs/latest/api/globals.html
翻译当作学习吧!
全局对象:
原文:These objects are available in all modules. Some of these objects aren't
actually in the global scope but in the module scope-this will be noted.
译文:这些对象在所有的模块中都可用。实际上有些对象并不在全局作用域范围中,但是在它的模块作用域中-这些会标识出来的。

原文: global  {object} The global namespace object.
   In browsers,the top-level scope is the global scope.That means that
in browsers if you're in the global scope var something will define a global variable.In Node this is different.The top-level scope is not the
global scope; var something inside a Node module will be local to that module.
译文: global  {对象} 全局命名空间对象。
    在浏览器中,最顶层的作用域是全局作用域。那意味着如果你在全局作用域中定义一个变量那就是一个全局变量。在Node中不是这样的。最顶层的作用域不是全局作用域;在一个Node模板中声明一个变量,你只是在某模块中声明了一个本地模块。

原文: process {Object} The process object.See the process  object section.

译文:  process  {对象}  这个进程对象。 查看进程对象这一节。

原文: console {Object} Used to print to stdout and stderr.See the stdio section.
译文:控制台 {对象} 用于打印到标准输出和错误输出。查看stdio 章节。

原文: Buffer {Object}  Used to handle binary data. See the buffer section.
译文:Buffer {对象}  用于处理二进制数据,请查看buffer章节。

原文: require() {Function}  To require modules.See the  Modules section. require isn't actually a  global but rather local each module.
译文;用于加载所需模块。参见Modules模块。require 实际是相对于每个模块的一个局部而不是一个全局的函数。

原文: require.resolve() Use the internal require() machinery to look up
the location of a module,but rather than loading the module,just return the resolved filename.
译文:require.resolve() 使用内部的require()机制来查看模块的位置,但是它只是返回解析后的名字,而不是加载模块。

原文:require.cache Object Modules are cached in this object when they
are required.By deleting a key value from this object,the next require
will reloaded the module.
译文: require.cache 对象 当模块被加载之后会缓存在这个对象中。在这个对象中删除一个键值的话,下一次,require将会重新加载模块。

原文: __filename {String}   The filename of the code being executed.This is the resolved absolute path of this code file. For a man program this is not necessarily the same filename used in the command line.The value inside a module is the path to that module file.
Example:running node exmaple.js from /Users/mjr
console.log(__filename);
// /users/mjr/exmaple.js
__filename isn't actually a global but rather local to each module.

译文:__filename {String} 将被执行的代码的文件名。这是已经被解析代码绝对路径。
对于主程序而言并不要求跟在命令行中使用的名字一样。在一个模块中的值 是对那个模块文件的路径。
示例:从/Users/mjr 运行 node example.js
   console.log(__filename);
// /Users/mjr/exmaple.js
__filename 实际是相对于各模块的本地变量而不是全局的。

原文:__dirname {String} The name of the directory that the currently
executing script resides in.
Example:running node example.js from /Users/mjr
console.log(__dirname);
// /Users/mjr
__dirname isn't actually a global but rather local to each module.

译文:#根__filename类同,暂不译。

原文:module {Object}  A reference to the current module.In particular module.exports is the same as the exports object. See src/node.js for more information. module isn't actually a global but rather local to each module.
译文: module {对象} 一个对当前模块的引用。特别地,module.exports 根exports对象相同。参见src/node.js了解更多。 module实际上是相对于各模块的局部对象而不是全局的。

原文:exports an object which is shared between all instances of the current module and made accessible through require().exports is the same as the module.exports object.See src/node.js for more information.export isn't actually a global but rather local to each module.
See the module system documentation for more information.
See the module section for more information.
译文:#与module类同不译。

原文:setTimeout(cb,ms)
     clearTimeout(t)
     setInterval(cb,ms)
     clearInterval(t)
   The timer functions are global variables.See the timers section.
0
0
分享到:
评论

相关推荐

    12课 NodeJS基础-第1天-{ 全局、核心对象、异步IO }.rar

    12课 NodeJS基础-第1天-{ 全局、核心对象、异步IO }.rar

    11课 NodeJS基础-第1天-{ 全局、核心对象、异步IO }.rar

    11课 NodeJS基础-第1天-{ 全局、核心对象、异步IO }

    Nodejs学习笔记之Global Objects全局对象

    Global Objects全局对象These objects are available in all modules. Some of these objects aren’t actually in the global scope but in the module scope – this will be noted. 这些对象在所有的模块中都

    深入理解Nodejs Global 模块

    浏览器上有自己的全局对象 window,同理, nodejs 下也有自己的全局对象 global,并且在各个模块下 都可以直接访问 global 对象。 在 nodejs 中,除了可以直接使用 V8 JavaScript 引擎中所支持的原生 JavaScript 的...

    nodejs初学者教程

    nodejs 简介与安装 全局对象与常用工具 http协议 node_Http_Server buffer fs_模块 模块系统 mongoDB_mongooose express 工程 cookie_session 部署_远程服务器

    extended.js:一个很棒的模块,它将属性分配给数组和Object全局对象,从而简要扩展了NodeJS

    扩展JS 一个很棒的模块,它将属性分配给数组和Object全局对象,从而简要扩展了NodeJS。关于该模块将附带分配给16个Array原型的函数和分配给9个Object全局对象的函数。安装需要NodeJS 12.0.0或更高版本npm install @...

    nodejs-lab:学习 NodeJS 的实践培训

    从 NodeJS 应用程序如何组织其源代码,到 NPM 如何处理应用程序依赖项,以及默认提供哪些全局对象。 CommonJS 模块 NodeJS 应用程序将它们的代码组织成模块。 关于如何用 JavaScript 编写模块有几个标准。 按照惯例...

    nodejs中全局变量的实例解析

    //耻辱的使用了全局变量 global.varA = abc; 关于global对象,实际使用中可以省去global. 他是默认的根作用域,相当于web环境中的window对象。 global 对象有几个挺有用的属性: console.log(__dirname);//当前路径...

    nodejs手册中文版.pdf

     Global Objects 全局对象 o global o process o require() o require.resolve() o require.paths o __filename o __dirname o module  Timers 定时器 o setTimeout(callback, delay, [arg], [...]) o ...

    Nodejs中的this详解

    以下内容都是关于在nodejs中的this而非javascript中的this,nodejs中的this和在浏览器中javascript中的this是不一样的。 在全局中的this console.log(this); {} this.num = 10; console.log(this.num); 10 console....

    浅谈Nodejs中的作用域问题

    以前学js的时候我们的全局对象是window,如: var a = 10; console.log(window.a); 我们定义的全局变量默认是给window添加一个属性或者方法。 function fn(){ var num = 22; } console.log(num); 报错,因为num是...

    nodejs-learning-guide:Nodejs学习笔记以及经验总结,公众号“程序猿小卡”

    Nodejs学习笔记阿里CBU前端团队招人,无论是serverless,跨端,...目录如下错误处理全局对象模块机制命令行设计-repl定时器安全加密-tls进阶使用express进阶:多模板引擎支持基于express + XHR的跨域资源请求微信公众号

    nodejs-mongodb-app:nodejs + mongodb应用程序组合框架(状态

    #应用程序结构: 通常有全局局部变量app通常在每个文件中都可用一个包含文件包含一个函数main(app)// app就像依赖注入{this //通常:this = app,但可能是另一个想要在此函数中扩展的对象this.foo = function...

    Nodejs 复制文件/文件夹的方法

    1.使用fs复制文件 使用fs对象的readFileSync,writeFileSync方法进行读写操作复制 cp.js function copyIt(from, to) { fs.writeFileSync(to, fs....这里使用了process对象,process对象是一个node的全局对象

    Nodejs实现多人同时在线移动鼠标的小游戏分享

    最近因为项目需要,所以研究了一下nodejs的websocket实现,socket.io,...3.服务器保存一个全局的坐标对象,并以客户端唯一编号为键值 4.有新连接来的时候,把坐标广播给其它客户端 5.客户端断开连接的时候,服务端删除它

    CUSTOMER-CLI:NodeJS CLI教程

    process 全局对象介绍和使用 process 对象是一个全局变量,它提供当前 Node.js 进程的有关信息,以及控制当前 Node.js 进程。 因为是全局变量,所以无需使用 require()。 编写一个nodejs命令行工具,process对象...

    vouchdb:在 nodejs 和浏览器中为 CouchDB 和 PouchDB 使用相同的基于 promise 的 api

    在 nodejs 中测试 测试更改提要 测试连续复制 取消小袋的复制 实现无缝仿真,从 api 的角度消除 pouch 和 couch 之间的所有差异。 测试冲突和解决方案 完成并编写适当的测试。 凭证数据库 使用誓言的 couchdb 和 ...

    node-api-study:nodejs api学习梳理

    nodejs api学习梳理###常用工具UtilitiesconsoleNode提供一个全局对象'console',你可以使用它输出字符串。1. `console.log` 输出字符串或者对象,输出对象时调用了util.inspect2. `console.warn`3. `console.trace`...

    程序员面试刷题的书哪个好-note-nodejs:笔记-nodejs

    内置对象 Array Object Date Math 在 Node 中为 JavaScript 提供了一些服务器级别的 API 文件操作的能力 http 服务的能力 模块系统概念 在 Node 中没有全局作用域的概念 在 Node 中,只能通过 require 方法来加载...

Global site tag (gtag.js) - Google Analytics