Skip to main content

this_object

Function this_object 

Source
pub fn this_object(
    interp: &mut Interp<'_>,
    this: &Value,
) -> JsResult<Gc<JsObject>>
Expand description

The this of a method call, as an object.

A primitive receiver is boxed: "abc".indexOf(…) reaches a method on String.prototype with a string this, and the method behaves as if it had an object.

This used to be a second, incomplete ToObject: it boxed by defining _value and nothing else, so a boxed string had no length and no index properties, and Array.prototype.map.call("ab", …) read nothing at all. Boxing now goes through the interpreter’s one implementation, which builds the String exotic object properly.