arguments-object.js 382 B

123456789101112131415
  1. test("basic arguments object", () => {
  2. function foo() {
  3. return arguments.length;
  4. }
  5. expect(foo()).toBe(0);
  6. expect(foo(1)).toBe(1);
  7. expect(foo(1, 2)).toBe(2);
  8. expect(foo(1, 2, 3)).toBe(3);
  9. function bar() {
  10. return arguments[1];
  11. }
  12. expect(bar("hello", "friends", ":^)")).toBe("friends");
  13. expect(bar("hello")).toBe(undefined);
  14. });