Why are arguments in JavaScript not preceded by the var keyword?

后端 未结 4 427
萌比男神i
萌比男神i 2021-01-12 02:05

This may be a silly question, but why are function arguments in JavaScript not preceded by the var keyword?

Why:

function fooAnything(anything) {
  r         


        
4条回答
  •  悲哀的现实
    2021-01-12 02:50

    It would be a redundant use of the var keyword. Items that appear in the parentheses that follow a function name declaration are explicitly parameters for the function.

提交回复
热议问题