pub fn numberify(&self, heap: &Heap) -> Option<JSNumber> {
        match self {
            JSValue::Undefined => None, // Some(f64::NAN),
            JSValue::Bool(b) => Some(if *b { 1.0 } else { 0.0 }),
            JSValue::Number(n) => Some(*n),
            JSValue::String(s) => s.parse::<JSNumber>().ok(),
            JSValue::Ref(Heap::NULL) => Some(0.0),
            JSValue::Ref(r) => {
                let object = heap.get(*r);
                if let Some(array) = object.as_array() {
                    match &array.storage[..] {
                        [] => Some(0.0),              // +[]  == 0
                        [val] => val.numberify(heap), // +[x] == x
                        _ => None,                    // +[x, y, ..] == NaN
                    }
                } else {
                    object.to_primitive(heap).and_then(|v| v.numberify(heap))
                }
            }
        }
    }
/// numberify() tries to make everything into a numeric value
/// for evalation in a numeric context.
/// It is slightly more strict than `+value` in JavaScript: only
/// `value.numberify().unwrap_or(f64::NAN)` corresponds to `+value` in JavaScript.
numberify() tries to make everything into a numeric value
for evalation in a numeric context.
numberify () tries to make everything into a numeric value for evalation in a numeric context .
pub fn numberify(&self, heap: &Heap) -> Option<JSNumber> {
        match self {
            JSValue::Undefined => None, // Some(f64::NAN),
            JSValue::Bool(b) => Some(if *b { 1.0 } else { 0.0 }),
            JSValue::Number(n) => Some(*n),
            JSValue::String(s) => s.parse::<JSNumber>().ok(),
            JSValue::Ref(Heap::NULL) => Some(0.0),
            JSValue::Ref(r) => {
                let object = heap.get(*r);
                if let Some(array) = object.as_array() {
                    match &array.storage[..] {
                        [] => Some(0.0),              // +[]  == 0
                        [val] => val.numberify(heap), // +[x] == x
                        _ => None,                    // +[x, y, ..] == NaN
                    }
                } else {
                    object.to_primitive(heap).and_then(|v| v.numberify(heap))
                }
            }
        }
    }
pub fn numberify ( & self , heap : & Heap ) -> Option < JSNumber > { match self { JSValue :: Undefined => None , // Some(f64::NAN), JSValue :: Bool ( b ) => Some ( if * b { 1.0 } else { 0.0 } ) , JSValue :: Number ( n ) => Some ( * n ) , JSValue :: String ( s ) => s . parse :: < JSNumber > ( ) . ok ( ) , JSValue :: Ref ( Heap :: NULL ) => Some ( 0.0 ) , JSValue :: Ref ( r ) => { let object = heap . get ( * r ) ; if let Some ( array ) = object . as_array ( ) { match & array . storage [ .. ] { [ ] => Some ( 0.0 ) , // +[]  == 0 [ val ] => val . numberify ( heap ) , // +[x] == x _ => None , // +[x, y, ..] == NaN } } else { object . to_primitive ( heap ) . and_then ( | v | v . numberify ( heap ) ) } } } }
numberify() tries to make everything into a numeric value
for evalation in a numeric context.
numberify () tries to make everything into a numeric value for evalation in a numeric context .
&self
heap
&Heap
&self
heap
&Heap