mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
LibJS: Make it possible to reference the "this" value in JavaScript
This commit is contained in:
parent
401becb922
commit
fecbef4ffe
1 changed files with 3 additions and 0 deletions
|
@ -144,6 +144,9 @@ void Interpreter::set_variable(const FlyString& name, Value value, bool first_as
|
|||
|
||||
Optional<Value> Interpreter::get_variable(const FlyString& name)
|
||||
{
|
||||
if (name == "this")
|
||||
return this_value();
|
||||
|
||||
for (ssize_t i = m_scope_stack.size() - 1; i >= 0; --i) {
|
||||
auto& scope = m_scope_stack.at(i);
|
||||
auto value = scope.variables.get(name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue