Skip to content

Commit

Permalink
Implement Object.prototype.toLocaleString() (#1875)
Browse files Browse the repository at this point in the history
It changes the following:
- Implement `Object.prototype.toLocaleString()`
  • Loading branch information
HalidOdat committed Feb 28, 2022
1 parent 73bcd42 commit 4292c19
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions boa_engine/src/builtins/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl BuiltIn for Object {
.method(Self::has_own_property, "hasOwnProperty", 1)
.method(Self::property_is_enumerable, "propertyIsEnumerable", 1)
.method(Self::to_string, "toString", 0)
.method(Self::to_locale_string, "toLocaleString", 0)
.method(Self::value_of, "valueOf", 0)
.method(Self::is_prototype_of, "isPrototypeOf", 1)
.static_method(Self::create, "create", 2)
Expand Down Expand Up @@ -529,6 +530,25 @@ impl Object {
Ok(format!("[object {tag_str}]").into())
}

/// `Object.prototype.toLocaleString( [ reserved1 [ , reserved2 ] ] )`
///
/// More information:
/// - [ECMAScript reference][spec]
/// - [MDN documentation][mdn]
///
/// [spec]: https://tc39.es/ecma262/#sec-object.prototype.tolocalestring
/// [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString
#[allow(clippy::wrong_self_convention)]
pub fn to_locale_string(
this: &JsValue,
_: &[JsValue],
context: &mut Context,
) -> JsResult<JsValue> {
// 1. Let O be the this value.
// 2. Return ? Invoke(O, "toString").
this.invoke("toString", &[], context)
}

/// `Object.prototype.hasOwnProperty( property )`
///
/// The method returns a boolean indicating whether the object has the specified property
Expand Down

0 comments on commit 4292c19

Please sign in to comment.