32 lines
1.0 KiB
Plaintext

== Why is this an issue?
Nested functions refer to the practice of defining a function within another function. These inner functions have access to the variables and parameters of the outer function, creating a closure.
While nesting functions is a common practice in JavaScript, deeply nested functions can make the code harder to read and understand, especially if the functions are long or if there are many levels of nesting.
This can make it difficult for other developers or even yourself to understand and maintain the code.
=== Noncompliant code example
With the default threshold of 4 levels:
[source,javascript]
----
function f() {
function f_inner() {
function f_inner_inner() {
function f_inner_inner_inner() {
function f_inner_inner_inner_inner() { // Noncompliant
}
}
}
}
}
----
== Resources
=== Documentation
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#nested_functions_and_closures[Nested functions and closures]