Is it possible to reflect the arguments of a Javascript function?

后端 未结 8 1764
孤城傲影
孤城傲影 2020-12-02 23:21

Is it possible to get all of the arguments a Javascript function is written to accept? (I know that all Javascript function arguments are \"optional\")? If

8条回答
  •  北海茫月
    2020-12-03 00:02

    JavaScript is a dialects of ECMAScript, according to ECMAScript standard, a function is also a object, and when a function is called, function can access arguments object, this arguments is array-like object, it has length property, so you can use arguments.length to traverse all arguments passed to this function. visit http://interglacial.com/javascript_spec/a-13.html#a-13.2.1 for more details.

提交回复
热议问题