Add timers to globals section
[platform/upstream/nodejs.git] / doc / api / globals.markdown
1 ## Global Objects
2
3 These object are available in the global scope and can be accessed from anywhere.
4
5 ### global
6
7 The global namespace object.
8
9 In browsers, the top-level scope is the global scope. That means that in
10 browsers if you're in the global scope `var something` will define a global
11 variable. In Node this is different. The top-level scope is not the global
12 scope; `var something` inside a Node module will be local to that module.
13
14 ### process
15
16 The process object. See the [process object](process.html#process) section.
17
18 ### require()
19
20 To require modules. See the [Modules](modules.html#modules) section.
21
22 ### require.resolve()
23
24 Use the internal `require()` machinery to look up the location of a module,
25 but rather than loading the module, just return the resolved filename.
26
27 ### require.paths
28
29 An array of search paths for `require()`.  This array can be modified to add
30 custom paths.
31
32 Example: add a new path to the beginning of the search list
33
34     require.paths.unshift('/usr/local/node');
35
36
37 ### __filename
38
39 The filename of the script being executed.  This is the absolute path, and not necessarily
40 the same filename passed in as a command line argument.
41
42 Example: running `node example.js` from `/Users/mjr`
43
44     console.log(__filename);
45     // /Users/mjr/example.js
46
47 ### __dirname
48
49 The dirname of the script being executed.
50
51 Example: running `node example.js` from `/Users/mjr`
52
53     console.log(__dirname);
54     // /Users/mjr
55
56
57 ### module
58
59 A reference to the current module. In particular
60 `module.exports` is the same as the `exports` object. See `src/node.js`
61 for more information.
62
63 ### setTimeout(cb, ms)
64 ### clearTimeout(t)
65 ### setInterval(cb, ms)
66 ### clearInterval(t)
67
68 The timer functions are global variables. See the [timers](timers.html) section.