0

const add = function(a, b) {
  return a + b;
}

add(1, 2, 3, 4, 5);
console.log(Object.getOwnPropertyDescriptors(add));

In this code, why can't I find length property of arguments object?

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Sein kim
  • 25
  • 4
  • Have you tried `arguments.length`?? – Pointy Aug 21 '23 at 15:19
  • 3
    And note that arguments are not properties of the function object. The number of arguments passed to a function on a particular function call can be determined *inside* the function, not outside. – Pointy Aug 21 '23 at 15:20
  • 1
    The ["length of a function"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) is how many parameters it _defines_. Obviously it makes no sense for the number it's _called with_ to be a property of the function, because that depends call-by-call on how many it's called with on each specific invocation. – jonrsharpe Aug 21 '23 at 15:30

0 Answers0