forked from nkronlage/JavaScripture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.jsdoc
More file actions
198 lines (138 loc) · 4.79 KB
/
global.jsdoc
File metadata and controls
198 lines (138 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
Global : Object
The following are properties of the global object. They can be accessed from
anywhere without additional qualifiers.
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1
----
NaN : Number
Floating point Not a Number. Signifies an error in a calculation.
**NaN** is never equal to another **Number**, even if it is **NaN**.
To check if something is **NaN**, use %%#isNaN|**isNaN()**%%.
<example>
console.log(NaN);
console.log(0/0);
console.log(Math.sqrt(-1));
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.1.1
----
Infinity : Number
Positive infinity.
<example>
console.log(Infinity);
console.log(1/0);
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.1.2
----
undefined: undefined
Returns the **undefined** type. This value signifies no value has been
set on a property or that a method returned no value.
<example>
var x = {};
console.log(x.foo);
var noReturn = function() {};
console.log(noReturn());
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.1.3
----
eval(code : String) : Object
Treats **code** as JavaScript and executes it, returning the result.
<example>
console.log(eval('1 + 1'));
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.1
----
parseInt(str : String, [base : Number]) : Number
Converts **str** into an integral number. If **base** is not specified, **parseInt**
will attempt to determine the base to use depending on the input. **parseInt** is
more forgiving than **Number(str)** (or equivalently **+str**) in that it will ignore
extra characters after the numeric portion of the string. If the first character
is not a valid number in the specified **base**, **parseInt** will return %%#NaN|**NaN**%%.
<example>
console.log(parseInt('12'));
console.log(parseInt('0x12')); // Detected hex
console.log(parseInt('012')); // Detected octal
console.log(parseInt('012', 10)); // Force decimal
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.2
----
parseFloat(str : String) : Number
Converts **str** into a floating point number.
<example>
console.log(parseFloat('3.14') * 2);
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.3
----
isNaN(x : Number) : Boolean
Returns **true** if **x** is %%/Number#NaN|**NaN**%%.
**NaN** is never equal to another **Number**, even if it is **NaN**,
so you must use **isNaN** to check for **NaN**.
If **x** is not a %%/Number|Number%%, it is first converted to a Number
before checking if it is NaN. Use %%/Number#isNaN|**Number.isNaN(x)**%%
to prevent any conversion from happening.
<example>
var x = 0/0;
console.log(x === NaN);
console.log(isNaN(x));
console.log();
// Compare Number.isNaN and global isNaN methods
console.log(Number.isNaN('NaN')); // 'NaN' is a string, not a Number
console.log(isNaN('NaN')); // The 'NaN' string is first converted to a Number
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.4
----
isFinite(x : Object) : Boolean
Returns **true** if **x** is not **NaN**, **+Infinity**, or **-Infinity**.
If **x** is not a %%/Number|Number%%, it is first converted to a Number
before checking if it is finite. Use %%/Number#isFinite|**Number.isFinite(x)**%%
to prevent any conversion from happening.
<example>
console.log(Number.isFinite(0/0)); // 0/0 is NaN
console.log(Number.isFinite(1/0)); // 1/0 is infinity
console.log(Number.isFinite(1.2)); // 1.2 is finite
console.log();
// Compare Number.isFinite and global isFinite methods
console.log(Number.isFinite('0')); // '0' is a string, not a Number
console.log(isFinite('0')); // The '0' string is first converted to a Number
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.5
----
decodeURI(encodedURI : String) : String
Returns a string that is the decoded version of %%#encodeURI|**encodeURI**%%.
<example>
console.log(decodeURI('http://foo/bar%20baz'));
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.1
----
decodeURIComponent(encodedURIComponent : String) : String
Returns a string that is the decoded version of %%#encodeURIComponent|**encodeURIComponent**%%.
<example>
console.log(decodeURIComponent('http%3A%2F%2Ffoo%2Fbar%20baz'));
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.2
----
encodeURI(uri : String) : String
Returns a string that is the encoded version of **uri**.
<example>
console.log(encodeURI('http://foo/bar baz'));
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.3
----
encodeURIComponent(component : String) : String
Returns an encoded version of **component** that is suitable as a uri
parameter.
<example>
console.log(encodeURIComponent('http://foo/bar baz'));
</example>
Spec:
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.4