mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:27:45 +00:00
LibJS: Add String.prototype.valueOf()
It should have its own and not inherit from the Object prototype.
This commit is contained in:
parent
8d7ec28924
commit
e9a0759b16
2 changed files with 7 additions and 0 deletions
|
@ -61,6 +61,7 @@ void StringPrototype::initialize(GlobalObject& global_object)
|
|||
define_native_function(vm.names.toLowerCase, to_lowercase, 0, attr);
|
||||
define_native_function(vm.names.toUpperCase, to_uppercase, 0, attr);
|
||||
define_native_function(vm.names.toString, to_string, 0, attr);
|
||||
define_native_function(vm.names.valueOf, value_of, 0, attr);
|
||||
define_native_function(vm.names.padStart, pad_start, 1, attr);
|
||||
define_native_function(vm.names.padEnd, pad_end, 1, attr);
|
||||
define_native_function(vm.names.trim, trim, 0, attr);
|
||||
|
@ -278,6 +279,11 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_string)
|
|||
return this_string_value(global_object, vm.this_value(global_object));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(StringPrototype::value_of)
|
||||
{
|
||||
return this_string_value(global_object, vm.this_value(global_object));
|
||||
}
|
||||
|
||||
enum class PadPlacement {
|
||||
Start,
|
||||
End,
|
||||
|
|
|
@ -28,6 +28,7 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(to_lowercase);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_uppercase);
|
||||
JS_DECLARE_NATIVE_FUNCTION(to_string);
|
||||
JS_DECLARE_NATIVE_FUNCTION(value_of);
|
||||
JS_DECLARE_NATIVE_FUNCTION(pad_start);
|
||||
JS_DECLARE_NATIVE_FUNCTION(pad_end);
|
||||
JS_DECLARE_NATIVE_FUNCTION(substring);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue