From d7073b9f3e9fe7b19e0863c0758b195675ca199d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 26 Mar 2020 12:02:18 +0100 Subject: [PATCH] LibJS: Add Value::is_array() --- Libraries/LibJS/Runtime/Value.cpp | 5 +++++ Libraries/LibJS/Runtime/Value.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Libraries/LibJS/Runtime/Value.cpp b/Libraries/LibJS/Runtime/Value.cpp index a865ba3048..675a938f14 100644 --- a/Libraries/LibJS/Runtime/Value.cpp +++ b/Libraries/LibJS/Runtime/Value.cpp @@ -33,6 +33,11 @@ namespace JS { +bool Value::is_array() const +{ + return is_object() && as_object()->is_array(); +} + String Value::to_string() const { if (is_boolean()) diff --git a/Libraries/LibJS/Runtime/Value.h b/Libraries/LibJS/Runtime/Value.h index f54135ab8a..5dfe600101 100644 --- a/Libraries/LibJS/Runtime/Value.h +++ b/Libraries/LibJS/Runtime/Value.h @@ -51,6 +51,7 @@ public: bool is_object() const { return m_type == Type::Object; } bool is_boolean() const { return m_type == Type::Boolean; } bool is_cell() const { return is_string() || is_object(); } + bool is_array() const; Value() : m_type(Type::Undefined)