What is Optional Chaining and Nullish Coalescing? (ES2020)

The Quick Answer

Optional Chaining

if (object.property){
variable = object.property;
}
variable = object?.property

Nullish Coalescing

myNewVariables = possibleVariable || defaultValue;
myNewVariables = possibleVariable ?? defaultValue;

Conclusion

Alex Merced is a Full Stack Developer, learn more about his work at AlexMercedCoder.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store