include::../description.adoc[]

== Noncompliant Code Example

----
function doSomething(a, b) { // "a" is unused
  return compute(b);
}
----

== Compliant Solution

----
function doSomething(b) {
  return compute(b);
}
----

== Exceptions

When writing function callbacks, some arguments might be required as part of the function signature, but not actually needed by the callback code. For instance, JQuery has the 'each' helper to iterate over arrays or objects, but using the counter 'i' should remain optional:


----
$(["first", "last"]).each(function (i, value) {
  computeSomethingWithValue(value);
});
----

So only unused arguments listed at the end of the argument list will be flagged with issues because they could be omitted from the function signature. Unused arguments which are followed by an argument that _is_ used will be ignored.


Examples :

----
var myFirsCallBackFunction = function (p1, p2, p3, p4) {  // p2 is ignored, but p4 is reported
                                              return p1 + p3; }

var mySecondCallBackFunction = function (p1, p2, p3, p4) {  // p1, p2 and p3 are ignored
                                              return p4; }

var myThirdCallBackFunction = function (p1, p2, p3, p4) {  // p1 is ignored but p3 and p4 are reported
                                              return p2; }
----

Further, when ``++arguments++`` is used in the function body, no parameter is reported as unused. 


----
function doSomething(a, b, c) {
  compute(arguments);
}
----

include::../see.adoc[]
