All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.javascript.rules.javascript.FunctionDeclarationsWithinBlocks.html Maven / Gradle / Ivy

Do not do this :

if (x) {
  function foo() {}
}

While most script engines support Function Declarations within blocks it is not part of ECMAScript. Worse implementations are inconsistent with each other. ECMAScript only allows for Function Declarations in the root statement list of a script or function. Instead use a variable initialized with a Function Expression to define a function within a block :

if (x) {
  var foo = function() {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy