`
zhangyaochun
  • 浏览: 2595528 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

node的Global Objects

阅读更多

 

    居然漏了这篇,补上:

 

    Global Objects

 

  • __dirname

     当前正在执行的脚本所在的目录名

 

//在/Users/mjr下执行node example.js
console.log(__dirname);    //   /Users/mjr

 

 

 

  • __filename

    当前正在执行的脚本所在的文件名【绝对路径】

 

//在/Users/mjr下执行node example.js
console.log(__filename);      // 返回 /Users/mjr/example.js

 

 

   

分享到:
评论

相关推荐

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

    在Node.js中,全局对象(Global Objects)扮演着至关重要的角色,它是所有模块都能访问的一组预定义的对象和函数。与浏览器环境不同,Node.js的顶级作用域并非全局作用域,而是模块作用域。这意味着在Node.js的模块...

    Learning.Node.Moving.to.the.Server-Side.2nd.Edition.14919

    Node Building Blocks: the Global Objects, Events, and Node’s Asynchronous Nature Chapter 3. Basics of Node Modules and Npm Chapter 4. Interactive Node with REPL and More on the Console Chapter 5. ...

    Node.js中文文档

    #### 六、GlobalObjects 全局对象 - **process**:提供了关于当前 Node.js 进程的信息以及控制它的方法。 - `process.exit(code)`:退出当前进程。 - `process.pid`:进程 ID。 - `process.platform`:运行平台...

    nodejs中文帮助文档

    Global Objects(全局对象)是Node.js中的全局变量。比如process对象可以获取到运行当前脚本的Node.js进程的信息,同时也可以用来终止进程。console对象可以用于输出日志到标准输出流或标准错误流。Buffer、process...

    node-corevis:根据使用 mdb(1) 从 node.js 核心转储收集的信息生成 HTML

    核心根据使用mdb(1)从核心转储收集的信息生成 HTML 示例: : 安装 [sudo] ... [root@test1 ~/node-corevis]# node examples/big-objects.jspid 9986Abort (core dumped)[root@test1 ~/node-corevis]# ./corevis.js /c

    nodejs中文文档.pdf

    **Global Objects** 包括Node.js环境中的一些全局变量和函数,如`process`对象,它提供了与Node.js进程交互的方法,比如获取进程ID、设置退出码、监听信号等。`global`对象则是所有全局变量的容器,尽管一般不推荐...

    python3.6.5参考手册 chm

    Python参考手册,官方正式版参考手册,chm版。以下摘取部分内容:Navigation index modules | next | Python » 3.6.5 Documentation » Python Documentation contents What’s New in Python ...

    nodejs中文帮助文档.pdf

    - **GlobalObjects全局对象** - **定义**: Node.js提供了一系列全局可用的对象,用于简化开发过程。 - **重要全局对象**: - `process`: 提供了访问Node.js进程信息和控制流程的方法。 - `Buffer`: 处理二进制...

    Programming Excel With Vba And .net.chm

    The Global Object Section 4.9. The WorksheetFunction Object Section 4.10. What You've Learned Chapter 5. Creating Your Own Objects Section 5.1. Modules Versus Classes Section 5.2. Add ...

    linux 10.2.0.1-10.2.0.5

    在升级过程中,可能需要调整 SGA (Shared Global Area) 的大小,以确保数据库能够高效运行: - **检查当前 SGA 设置:** - `SQL> show parameters ga;` - **调整 SGA 目标值:** - 如果发现当前 SGA 设置过小,...

    Graph Neural Networks_ A Review of Methods and Applications----清华大学周杰.pdf

    This iterative process allows each node to capture information from its neighborhood, enabling the model to learn representations that consider both local and global structures of the graph. ...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    list (contains flex-objects with Parent = Nil and the owner = Owner). - FIX: In BCB a problem occurred with TFlexText.DrawText, which for some reason kept being renamed by linker to DrawTextA. For ...

    oracle 高级复制操作步骤,花了很久才研究透彻。

    ADD REPLICATION NODE node_name; ``` 2. **测试是否在复制任务中**: ```sql -- 查看复制任务状态 SELECT * FROM dba_replication_status; ``` #### 七、使同步组的状态由停顿改为正常 为了使同步组正常...

    LABVIEW 语言中英文对照表速记

    此外,还有对象(Objects)、常量(Constant)、本地变量(Local Variable)和全局变量(Global Variable)等概念。 在前面板中,Control和Indicator是基本元素,RefNum是用于标识对象的枚举或标志号。模板...

Global site tag (gtag.js) - Google Analytics