Skip to main content

to_number_value

Function to_number_value 

Source
pub fn to_number_value(v: &Value) -> Result<f64, String>
Expand description

ToNumber(v) — ECMA-262 7.1.4 — with the object case going through ToPrimitive(v, number) first, so +{ valueOf() { return 7 } } is 7 and +new Date(0) is 0. JsHost::to_number alone cannot do this: it runs under the host borrow and so can never invoke a JS valueOf.