One-dimensional function parameters and private variables

When formatting or converting some parameters of a function in JavaScript, I usually create private variables of the same name (private variables with the same names as function parameters):

function myFunction(param) {
  var param = Math.floor(param);
  // More code referencing param many times here...
}

Question: Is it considered bad practice? Is there any flaw that I should worry about?

+5
source share
1 answer

var is ignored by the interpreter, and this does not define the second variable. This way you can also save time by entering 4 extra characters :)

same as doing:

var var1 = 2;
var var1 = 3;
+3
source

All Articles