jeudi 2 septembre 2021

Function name shadowed by that function's parameter name

Warning: The 5th edition of ECMAScript (ES5) forbids use of arguments.callee() in strict mode. Avoid using arguments.callee() by either giving function expressions a name or use a function declaration where a function must call itself. [MDN]

How does one reference the o function within itself in the following situation?

function o(o) { o(); }
o('not a function'); // TypeError: o is not a function

EDIT:

Why not rename the parameter/function?

  1. I am debugging thousands of files of obfuscated JavaScript code.
  2. My own personal opinion is that this problem should be avoidable via reflection alone, not refactoring.




Aucun commentaire:

Enregistrer un commentaire