V
V
Vadim Remin2015-11-17 07:55:27
JavaScript
Vadim Remin, 2015-11-17 07:55:27

JS: Coincidence of the name of a function parameter and the name of a local variable in the function that called it - an anti-pattern?

Good afternoon, is
the coincidence of the name of a function parameter and the name of a local variable in the function that called it an antipattern?

function bigFoo () {
  var x = 100;
  return x = smallFoo(x);
}

function smallFoo(x) {
  return x+=10;
}

bigFoo();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xmoonlight, 2015-11-17
@dkudrin1

The variable names are the same, but their scopes and, accordingly, their references are different.
This is not an anti-pattern.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question