设为首页 收藏本站
查看: 662|回复: 0

[经验分享] nodejs全局对象

[复制链接]

尚未签到

发表于 2017-2-21 09:52:30 | 显示全部楼层 |阅读模式
下面的东西基本是翻译自以下地址:
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.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-345098-1-1.html 上篇帖子: 【转】学习NodeJS第三天:打造Nodejs的调试环境 下篇帖子: nodejs 全局变量
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表