DEV Community

Discussion on: JavaScript: Skip Values In Destructuring

Collapse
 
ntvinhit profile image
Nguyį»…n Trį»ng VÄ©nh

And how about useless arguments in a callback when you can't use a blank as a useless variable?
Example:

const measureCallback = (x, y, width, height) => {
// I just need width, height only;
}
this.measure(measureCallback);

Collapse
 
mattbag00 profile image
Matt Bagni

I think you can use the rest operator (...args)

Collapse
 
ntvinhit profile image
Nguyį»…n Trį»ng VÄ©nh

so:
const measureCallback = (...args) => {
const [ , , width, height] = args;
}

I dont think this is a good idea