Wildcard
# Claude Pache (13 years ago)
I think that "nothing" wins over "dot" or "underscore" for marking unused positions, for one simple reason: it is implemented for years in every engines in constructs like:
var myArray = [ , , third]
So it seems more natural to me to have something like: function( , , z) { /* ... */ }
But anyway, if one day I'll need more than one unused parameter, I would first ask me seriously if it would not be better to refactor my function's signature with something like:
function f({z: z}) { /* ... */ } f({x: first, y: second, z: third})
instead of:
function f( , , z) { /* ... */ } f(first, second, third)
Claude
Le 30 déc. 2012 à 13:06, Axel Rauschmayer <axel at rauschma.de> a écrit :
It wouldn’t be breaking if it was the only identifier that one was allowed to use multiple time, right?
But I do like the idea of the dot. Would be nice for destructuring arrays, too:
let [., ., third] = myArray;