🌐
JavaScript.info
javascript.info › tutorial › the javascript language › objects: the basics
Optional chaining '?.'
E.g. in user?.address.street.name the ?. allows user to safely be null/undefined (and returns undefined in that case), but that’s only for user. Further properties are accessed in a regular way. If we want some of them to be optional, then we’ll need to replace more .
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Optional_chaining
Optional chaining (?.) - JavaScript | MDN
The optional chaining (?.) operator accesses an object's property or calls a function. If the object accessed or function called using this operator is undefined or null, the expression short circuits and evaluates to undefined instead of throwing an error.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-optional-chaining
JavaScript Optional Chaining - GeeksforGeeks
The Optional Chaining Operator allows a developer to handle many of those cases without repeating themselves by assigning intermediate results in temporary variables: ... Note: If this code gives any error try to run it on online JavaScript editor.
Published   June 22, 2020
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
What Is the Optional Chaining Operator, and How Does It Work? - JavaScript - The freeCodeCamp Forum
April 8, 2025 - TLDR: Optional Chaining Operator is for objects, not properties? https://www.w3schools.com/jS/js_2020.asp " The Optional Chaining Operator returns undefined if an object is undefined or null (instead of throwing an er…
🌐
W3Schools
w3schools.io › javascript › es11-optional-chaining
ES2020(ES11) - Javascript Optional Chaining Operator - w3schools
This tutorial covers the latest javascript features, Optional Chaining Operator released in 2020. ES11 or ES2020 or EcmaScript2020 .
🌐
W3Schools
w3schools.com › js › js_2020.asp
JavaScript 2020
The Optional Chaining Operator returns undefined if an object property is undefined or null (instead of throwing an error).
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript tutorial › javascript optional chaining operator
JavaScript Optional Chaining Operator (?.)
December 17, 2023 - In this tutorial, you'll learn about the optional chaining operator (?.) that simplifies the way to access values through connected objects
🌐
freeCodeCamp
freecodecamp.org › news › optional-chaining-javascript
Optional Chaining in JavaScript – Explained with Examples
February 13, 2024 - The optional chaining operator (?.) allows you to access properties or methods without the need for explicit null or undefined checks. If any intermediate property in the chain is null or undefined, the expression short-circuits, and the result ...
🌐
W3Schools
w3schools.com › nodejs › nodejs_es6.asp
Node.js ES6+ Features
Modern JavaScript introduces syntax to safely access nested properties and provide fallback values. Optional chaining lets you access deeply nested object properties without worrying about null or undefined values in the chain.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-optional-chaining
How to Use Optional Chaining in JavaScript
February 7, 2022 - The optional chaining operator ?. takes the reference to its left and checks if it is undefined or null. If the reference is either of these nullish values, the checks will stop and return undefined.
Find elsewhere
🌐
Codecademy
codecademy.com › docs › javascript › optional chaining
JavaScript | Optional Chaining | Codecademy
August 7, 2025 - The optional chaining operator allows safe access to nested object properties or methods without having to explicitly check if intermediate properties exist.
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_optional_chaining.htm
JavaScript - Optional Chaining
When any object property doesn't exist, the optional chain stops the code execution and returns undefined. If you use the JavaScript nullish coalescing operator with it, you can return the default value when the object property doesn't exist.
🌐
W3Schools
w3schools.com › jsref › jsref_oper_optional.asp
JavaScript Optional Chaning Operator
Optional Chaning is a JavaScript 2020 feature. ES 2020 is supported in all modern browsers since September 2020: ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com
🌐
Dmitri Pavlutin
dmitripavlutin.com › javascript-optional-chaining
How to Use JavaScript Optional Chaining
Optional chaining accesses properties from deep of nested objects without prop existence verification and intermediate variables boilerplates.
🌐
V8
v8.dev › features › optional-chaining
Optional chaining · V8
We could change name?.length to name.length. Then, if name were an empty string, we would still get the correct 0 length. That is because the empty string is a falsy value: it behaves like false in an if clause. The optional chaining operator fixes this common source of bugs.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-optional-chaining-explained
JavaScript Optional Chaining `?.` Explained - How it Works and When to Use it
August 25, 2020 - let familyTree = { us: { children: {} } } // with _.get const grandChildren = _.get(familyTree, 'us.children.theirChildren', 'got no kids' ); //with optional chaining and null coalescing const nullCoalescing = familyTree?.us?.children?.theirChildren ?? 'got no kids' console.log(nullCoalescing) //got no kids · It also works for objects that may be null or undefined: ... Try it in your browser's console: This is a recent addition and old browsers may need polyfills. You can try it in Chrome or Firefox in the browser's console. If it doesn't work, try turning on JavaScript experimental features by visiting chrome://flags/ and enabling "Experimental JavaScript".
🌐
W3Schools
w3schools.com › typescript › typescript_null.php
TypeScript Null & Undefined
Optional chaining is a JavaScript feature that works well with TypeScript's null handling.
🌐
Stack Overflow
stackoverflow.com › questions › 75322578 › how-do-you-get-data-showing-with-typescript-optional-chaining
How do you get data showing with TypeScript Optional Chaining - Stack Overflow
"If someone can give me a good understanding on how it works both ways" — This is just a combination of some super-basic bits of JS (if, object properties, function calls, and variables) and the optional chaining operator which is what the tutorial you are reading is trying to teach you. It's really unclear what you don't understand. ... Consoles are in JavaScript function, I get that because there are 2 conditions.
🌐
Mimo
mimo.org › glossary › javascript › optional-chaining
JavaScript Optional Chaining: Syntax, Usage, and Examples
Optional chaining looks like a tiny question mark with a dot: ?.. You place it right before the property, index, or function call you want to access. ... Become a full-stack developer. Learn HTML, CSS, JavaScript, and React as well as NodeJS, Express, and SQL