diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 159421fcd4..c0cf4b1dff 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -203,17 +203,32 @@ DeprecatedString number_to_string(double d, NumberToStringMode mode) // 7.2.2 IsArray ( argument ), https://tc39.es/ecma262/#sec-isarray ThrowCompletionOr Value::is_array(VM& vm) const { + // 1. If argument is not an Object, return false. if (!is_object()) return false; - auto& object = as_object(); + + auto const& object = as_object(); + + // 2. If argument is an Array exotic object, return true. if (is(object)) return true; + + // 3. If argument is a Proxy exotic object, then if (is(object)) { - auto& proxy = static_cast(object); + auto const& proxy = static_cast(object); + + // a. If argument.[[ProxyHandler]] is null, throw a TypeError exception. if (proxy.is_revoked()) return vm.throw_completion(ErrorType::ProxyRevoked); - return Value(&proxy.target()).is_array(vm); + + // b. Let target be argument.[[ProxyTarget]]. + auto const& target = proxy.target(); + + // c. Return ? IsArray(target). + return Value(&target).is_array(vm); } + + // 4. Return false. return false; }