function-this-in-arguments.js 387 B

12345678910111213141516
  1. test("basic functionality", () => {
  2. expect(typeof this).toBe("object");
  3. expect(this).toBe(globalThis);
  4. });
  5. test("this inside instantiated functions is not globalThis", () => {
  6. let functionThis;
  7. function Foo() {
  8. this.x = 5;
  9. functionThis = this;
  10. }
  11. new Foo();
  12. expect(typeof functionThis).toBe("object");
  13. expect(functionThis.x).toBe(5);
  14. });