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

org.sonar.l10n.javascript.Semicolon.html Maven / Gradle / Ivy

In JavaScript semicolons is an optional statement separator. But this can lead to some ambiguities and here is an example of ambiguous code that breaks in the absence of a semicolon :

// define a function
var fn = function () {
  //...
} // semicolon missing at this line

// then execute some code inside a closure
(function () {
  //...
})();
This will be interpreted as:
var fn = function () {
  //...
}(function () {
  //...
})();

We end up passing the second function as an argument to the first function and then trying to call the result of the first function call as a function. The second function will fail with a "... is not a function" error at runtime.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy