StackOverflow - javascript, eslint, airbnb-js-styleguide

how do you style (big) short-circuit assignment in javascripts?

If you looking to reduce the length of the line, one possibility is to use destructuring assignment on the content object to first get the related properties. On a second step, you can use template literals to generate the default value assigned to result in case aPossibleValue results on a falsy value. Something like this: let {aPossibleValue, type, slug} = content; var result = aPossibleValue || $el.data('root-path') + `${type}/something/${slug}`; But you should note, these are ES6 features, not supported on some browsers and/or versions. So, always check the browser compatibility section. In the case you can't have access this luxury, I will go with something like this: let val = content.aPossibleValue, type = content.type, slug = content.slug; var result = val | $el.data('root-path') + type + '/something/' + slug;

Was this helpful?

Have a different question?

Can't find the answer you're looking for? Submit your own question to our community.

🛎️ Get Weekly OTA Fixes

New answers, vendor issues, and updates — straight to your inbox.