This article covers features introduced in SpiderMonkey 17
Convert any JavaScript value to a double.
Syntax
bool JS::ToNumber(JSContext *cx, JS::HandleValue v, double *out);
Name | Type | Description |
---|---|---|
cx |
JSContext * |
The context in which to perform the conversion. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext . |
v |
JS::HandleValue |
The value to convert. |
out |
double * |
Out parameter. On success, *out receives the converted floating-point value. |
Description
JS::ToNumber
converts a JavaScript value to a number. It implements the ToNumber operator described in ECMA 262-3 §9.3.
On success, JS::ToNumber
stores the converted value in *out
and returns true
. On error or exception, it returns false
, and the value left in *out
is undefined.