serenity/Userland/Libraries/LibJS/Tests/functions/function-this-in-arguments.js
2021-01-12 12:17:46 +01:00

16 lines
387 B
JavaScript

test("basic functionality", () => {
expect(typeof this).toBe("object");
expect(this).toBe(globalThis);
});
test("this inside instantiated functions is not globalThis", () => {
let functionThis;
function Foo() {
this.x = 5;
functionThis = this;
}
new Foo();
expect(typeof functionThis).toBe("object");
expect(functionThis.x).toBe(5);
});