diff options
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index a32565fa55..9e9d099e87 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -228,6 +228,12 @@ FunctionObject& Value::as_function() return static_cast<FunctionObject&>(as_object()); } +FunctionObject const& Value::as_function() const +{ + VERIFY(is_function()); + return static_cast<FunctionObject const&>(as_object()); +} + // 7.2.4 IsConstructor ( argument ), https://tc39.es/ecma262/#sec-isconstructor bool Value::is_constructor() const { diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 626500d4e0..feef1475c2 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -240,6 +240,7 @@ public: Array& as_array(); FunctionObject& as_function(); + FunctionObject const& as_function() const; i32 as_i32() const; u32 as_u32() const; |