ソースを参照

LibJS: Add Value::is_array()

Andreas Kling 5 年 前
コミット
d7073b9f3e
2 ファイル変更6 行追加0 行削除
  1. 5 0
      Libraries/LibJS/Runtime/Value.cpp
  2. 1 0
      Libraries/LibJS/Runtime/Value.h

+ 5 - 0
Libraries/LibJS/Runtime/Value.cpp

@@ -33,6 +33,11 @@
 
 
 namespace JS {
 namespace JS {
 
 
+bool Value::is_array() const
+{
+    return is_object() && as_object()->is_array();
+}
+
 String Value::to_string() const
 String Value::to_string() const
 {
 {
     if (is_boolean())
     if (is_boolean())

+ 1 - 0
Libraries/LibJS/Runtime/Value.h

@@ -51,6 +51,7 @@ public:
     bool is_object() const { return m_type == Type::Object; }
     bool is_object() const { return m_type == Type::Object; }
     bool is_boolean() const { return m_type == Type::Boolean; }
     bool is_boolean() const { return m_type == Type::Boolean; }
     bool is_cell() const { return is_string() || is_object(); }
     bool is_cell() const { return is_string() || is_object(); }
+    bool is_array() const;
 
 
     Value()
     Value()
         : m_type(Type::Undefined)
         : m_type(Type::Undefined)