mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 18:37:58 +03: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
Notes:
sideshowbarker
2024-07-18 12:45:16 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/e9a0759b162 Pull-request: https://github.com/SerenityOS/serenity/pull/7846
@ -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…
Reference in New Issue
Block a user