mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +00:00
LibJS: Add String.prototype.toUpperCase()
This commit is contained in:
parent
727031ac1b
commit
22f20cd51d
4 changed files with 31 additions and 0 deletions
|
@ -45,6 +45,7 @@ StringPrototype::StringPrototype()
|
|||
put_native_function("startsWith", starts_with, 1);
|
||||
put_native_function("indexOf", index_of, 1);
|
||||
put_native_function("toLowerCase", to_lowercase, 0);
|
||||
put_native_function("toUpperCase", to_uppercase, 0);
|
||||
}
|
||||
|
||||
StringPrototype::~StringPrototype()
|
||||
|
@ -154,6 +155,14 @@ Value StringPrototype::to_lowercase(Interpreter& interpreter)
|
|||
return js_string(interpreter, string_object->primitive_string()->string().to_lowercase());
|
||||
}
|
||||
|
||||
Value StringPrototype::to_uppercase(Interpreter& interpreter)
|
||||
{
|
||||
auto* string_object = string_object_from(interpreter);
|
||||
if (!string_object)
|
||||
return {};
|
||||
return js_string(interpreter, string_object->primitive_string()->string().to_uppercase());
|
||||
}
|
||||
|
||||
Value StringPrototype::length_getter(Interpreter& interpreter)
|
||||
{
|
||||
auto* this_object = interpreter.this_value().to_object(interpreter.heap());
|
||||
|
|
|
@ -43,6 +43,7 @@ private:
|
|||
static Value starts_with(Interpreter&);
|
||||
static Value index_of(Interpreter&);
|
||||
static Value to_lowercase(Interpreter&);
|
||||
static Value to_uppercase(Interpreter&);
|
||||
|
||||
static Value length_getter(Interpreter&);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue