summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-07-05 17:19:46 +0100
committerLinus Groh <mail@linusgroh.de>2021-07-05 18:19:45 +0100
commit4f2af65836230950c63ce26b56ab64a2b699f531 (patch)
tree4c502ed4c097383032ed8426c9ba66b3eb6c2c7d /Userland
parent8195c31965ce687f92e82341de05d5913b97bafb (diff)
downloadserenity-4f2af65836230950c63ce26b56ab64a2b699f531.zip
LibJS: Add spec step comments to Object.hasOwn()
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
index 44b543ea90..7c555ef54d 100644
--- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp
@@ -409,13 +409,18 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::create)
// 1 Object.hasOwn ( O, P ), https://tc39.es/proposal-accessible-object-hasownproperty/#sec-object.hasown
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::has_own)
{
+ // 1. Let obj be ? ToObject(O).
auto* object = vm.argument(0).to_object(global_object);
if (vm.exception())
return {};
- auto property_key = vm.argument(1).to_property_key(global_object);
+
+ // 2. Let key be ? ToPropertyKey(P).
+ auto key = vm.argument(1).to_property_key(global_object);
if (vm.exception())
return {};
- return Value(object->has_own_property(property_key));
+
+ // 3. Return ? HasOwnProperty(obj, key).
+ return Value(object->has_own_property(key));
}
// 20.1.2.1 Object.assign ( target, ...sources ), https://tc39.es/ecma262/#sec-object.assign