Just wrote a note about a little gotcha with default values for destructured properties of parameter objects in JavaScript that has gotten me a few times:
#JavaScript #destructuring #defaults #parameterObjects #web #dev
Just wrote a note about a little gotcha with default values for destructured properties of parameter objects in JavaScript that has gotten me a few times:
#JavaScript #destructuring #defaults #parameterObjects #web #dev
@aral Wouldn't just = {} work? Why repeat the parameters?
@zmicier Why yes, it does and it makes perfect sense too, thanks :) (This is why I post these things – there’s always someone who can point out a better way of doing things ;)
@zmicier PS. Updated the gist with your contribution – thanks agian:
@serapath Yep, that’s what @zmicier was saying too :) Updated the gist with the optimisation :)
constructor ({x = 1, y = 2} = {})
solves it
076萌SNS is a social network, courtesy of 076. It runs on GNU social, version 2.0.2-beta0, available under the GNU Affero General Public License.
All 076萌SNS content and data are available under the Creative Commons Attribution 3.0 license.