Skip to content

Commit 98b8a99

Browse files
committed
chore: Node 全局对象
1 parent 8cc4ed3 commit 98b8a99

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

NodeJS/sandboxs/GlobalObject.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const timerId = setTimeout(() => { }, 1000)
2+
console.log(timerId) // 浏览器计时器ID是数字,Node中是对象
3+
4+
console.log(__dirname) // (webpack)
5+
console.log(globalThis.__dirname)
6+
console.log(__filename)
7+
8+
const bufferArr = Buffer.from("ceilf6", "utf-8")
9+
console.log(bufferArr) // <Buffer 63 65 69 6c 66 36>
10+
11+
console.log(process.cwd())
12+
/*
13+
a86198@wangjinghongdeMacBook-Pro Lab % node NodeJS/sandboxs/index.js
14+
/Users/a86198/Desktop/Lab
15+
*/
16+
17+
// for (let i = 0; i < 10; i++) {
18+
// console.log(i)
19+
// if (i === 3)
20+
// process.exit(0) // '提前退出')
21+
// }
22+
// console.log('后面退出')
23+
24+
console.log(process.argv) // 获取命令的所有 args
25+
/*
26+
node "/Users/a86198/Desktop/Lab/NodeJS/sandboxs/index.js" ceilf6 so handsome
27+
[
28+
'/opt/homebrew/Cellar/node/24.7.0/bin/node',
29+
'/Users/a86198/Desktop/Lab/NodeJS/sandboxs/index.js',
30+
'ceilf6',
31+
'so',
32+
'handsome'
33+
]
34+
*/
35+
36+
console.log(process.platform) // darwin // Apple 开发的一个类 Unix 操作系统
37+
38+
// process.kill(49757)
39+
40+
console.log(process.env) // 环境变量 键值对

NodeJS/sandboxs/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)