mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
LibJS: Implement 'in' operator
This commit is contained in:
parent
396ecfa2d7
commit
11728b7db5
6 changed files with 54 additions and 0 deletions
|
@ -382,6 +382,14 @@ Value eq(Interpreter& interpreter, Value lhs, Value rhs)
|
|||
return Value(false);
|
||||
}
|
||||
|
||||
Value in(Interpreter& interpreter, Value lhs, Value rhs)
|
||||
{
|
||||
if (!rhs.is_object())
|
||||
return interpreter.throw_exception<TypeError>("'in' operator must be used on object");
|
||||
|
||||
return Value(rhs.as_object().get(lhs.to_string()).has_value());
|
||||
}
|
||||
|
||||
Value instance_of(Interpreter&, Value lhs, Value rhs)
|
||||
{
|
||||
if (!lhs.is_object() || !rhs.is_object())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue