Skip to content

Commit b4f32ae

Browse files
authored
Merge pull request #138 from nycdotnet/patch-1
Update docs to explain behavior of calling Big with undefined without new
2 parents 7c990e6 + 8ebbddd commit b4f32ae

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

doc/bigAPI.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,31 @@ <h5 id="big">
154154
recommended exponent magnitude is 1000000.
155155
</p>
156156
<p>Returns a new Big number object with value <code>n</code>.</p>
157-
<p>Throws on an invalid <code>n</code>.</p>
157+
<p>Throws on an invalid <code>n</code> when called with <code>new</code>.</p>
158158
<p>
159159
To create additional Big number constructor functions each with their own
160160
separate configuration see <a href='#multiple'>below</a>.
161161
</p>
162162
<pre>
163163
x = new Big(9) // '9'
164164
y = new Big(x) // '9'
165-
Big(435.345) // 'new' is optional
166165
new Big('5032485723458348569331745.33434346346912144534543')
167166
new Big('4.321e+4') // '43210'
168-
new Big('-735.0918e-430') // '-7.350918e-428'</pre>
169-
167+
new Big('-735.0918e-430') // '-7.350918e-428'
168+
Big(435.345) // '435.345' ('new' keyword is optional *)
169+
Big(undefined) // Big constructor *
170+
Big(void 0) // Big constructor *
171+
new Big(undefined) // thrown Invalid number Error
172+
new Big(void 0) // thrown Invalid number Error
173+
</pre>
170174

175+
<p>
176+
* Using the <code>new</code> keyword with Big is optional, but if the value of
177+
<code>n</code> is <code>undefined</code> or <code>void 0</code>, then the
178+
call to Big() will return a new Big constructor rather than a Big instance.
179+
If you would prefer <code>undefined</code> or <code>void 0</code> to throw an
180+
Invalid number error, please use <code>new</code>.
181+
</p>
171182

172183
<h4 id="constructor-properties">Properties</h4>
173184

0 commit comments

Comments
 (0)