1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

LibJS: Add the Object.getOwnPropertySymbols method

This commit is contained in:
Idan Horowitz 2021-06-12 17:41:13 +03:00 committed by Linus Groh
parent a2da3f97ef
commit bd9e20ef79
5 changed files with 44 additions and 15 deletions

View file

@ -33,6 +33,7 @@ void ObjectConstructor::initialize(GlobalObject& global_object)
define_native_function(vm.names.is, is, 2, attr);
define_native_function(vm.names.getOwnPropertyDescriptor, get_own_property_descriptor, 2, attr);
define_native_function(vm.names.getOwnPropertyNames, get_own_property_names, 1, attr);
define_native_function(vm.names.getOwnPropertySymbols, get_own_property_symbols, 1, attr);
define_native_function(vm.names.getPrototypeOf, get_prototype_of, 1, attr);
define_native_function(vm.names.setPrototypeOf, set_prototype_of, 2, attr);
define_native_function(vm.names.isExtensible, is_extensible, 1, attr);
@ -74,6 +75,14 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_names)
return Array::create_from(global_object, object->get_own_properties(PropertyKind::Key, false, GetOwnPropertyReturnType::StringOnly));
}
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_symbols)
{
auto* object = vm.argument(0).to_object(global_object);
if (vm.exception())
return {};
return Array::create_from(global_object, object->get_own_properties(PropertyKind::Key, false, GetOwnPropertyReturnType::SymbolOnly));
}
JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_prototype_of)
{
auto* object = vm.argument(0).to_object(global_object);