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
GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.
All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.