How to best mark parameter as ignored
I'm using require.js and one of my modules requires another one, but is
not interested in its export (it's a jQuery plugin), i.e. in the code
define(['jquery', 'jquery.mousewheel', 'fabric'], function ($, something,
fabric) {
// ...
}
I'm not interested in something. Of course I can move the dependencies of
which results I'm not interested in to the end of the array and just omit
the corresponding "trailing" parameters to my function, but for
readability I'd like to keep them as shown. Which leads me to the
question...
What is the JavaScript idiom for marking ignored parameters in function
definition?
Of course I know I can use any name which discourages me from using the
variable:
someMethodWithCallback(1, 2, 3, function (dx, notinterested1,
notinterested2, point) {
// ...
});
and was quite surprised that the following works (in Chrome at least)
(because undefined is not a keyword):
someMethodWithCallback(1, 2, 3, function (dx, undefined, undefined, point) {
// ...
});
but of course changing undefined value inside the function is potentially
very error-prone...
To ignore parameter value Perl has undef, StandardML has _; has JavaScript
anything like that, at least on "folklore" level?
No comments:
Post a Comment