0

Is this code valid?

var myfunc1 = function( parameter ) {
    parameter = smthg || 0;
    //code here
}

var myfunc2 = function( parameter ) {
    parameter = smthg || 0;
    //code here
}

In jQuery, developers use single word parameter like e,t,n many times in their library, so I guess it is safe to use the same parameter again and again?

crezc3nt
  • 313
  • 4
  • 12

1 Answers1

0

Yes, the arguments for a function are local variable declarations scoped to the function which declares them, and are completely independent of any other function.

They have the same scope as variables declared within the function, for example:

function myFunction1() {
    var localVar=0;
    ...
}

function myFunction2() {
    var localVar=0;
    ...
}
Lawrence Dol
  • 63,018
  • 25
  • 139
  • 189