What is a good JavaScript technique/convention/standard to avoid unused variables
?
For example, if I'm calling a function like below and I just want to use the 3rd parameter, what do I do with the 1st and 2nd parameters?
$.ajax({
success: function(first, second, third){
console.log("just using: " + third);
}
});
Ignore them.
(You could define your function as function () {
and then use var third = arguments[2];
but that doesn't lend itself to very readable code).
this first, second
params if they have no references will be deleted by Garbage collector, to help him to do it you can make next in the start of your function
success: function(first, second, third){
first = second = null;
......
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With