About 54 results
Open links in new tab
  1. javascript - How can I use optional chaining with arrays and functions ...

    Jan 7, 2020 · Optional chaining isn't just a TypeScript thing - it is a finished proposal in plain JavaScript too. It can be used with bracket notation like above, but it can also be used with dot notation property …

  2. How does the JavaScript optional chaining (?.) operator works?

    In both your first and second example, the optional chaining operator makes no difference from the regular property accessor. obj?.b simply reads b (which is undefined), since obj is not nullish.

  3. javascript - Using optional chaining operator for object property ...

    Nov 9, 2019 · 25 The Optional Chaining operator is ?. Here are some examples for nullable property and function handling.

  4. javascript - JS optional chaining clarification - Stack Overflow

    Mar 24, 2022 · Optional chaining tells JavaScript to complete the method/read the key, but if it doesn't exist, instead of throwing an error, just return undefined. It also works with arrays; the same way! If, …

  5. Optional Chaining in JavaScript - Stack Overflow

    In plain JavaScript you have to do type checks or structure your code so that you know an object will exist. CoffeeScript, a language that compiles down to JavaScript, provides an existential operator ?. …

  6. How to use optional chaining in Node.js 12 - Stack Overflow

    Jan 3, 2020 · 4 Optional Chaining will be implemented with Node.js v14, which will be released on 20/04/2020. By now, you may use Babel with @babel/plugin-proposal-optional-chaining.

  7. Best alternative for optional chaining in javascript

    Jun 17, 2022 · Best alternative for optional chaining in javascript Asked 3 years, 7 months ago Modified 3 years, 7 months ago Viewed 6k times

  8. javascript - Should we use ! (non-null assertion) or ?. (optional ...

    Jan 20, 2021 · Optional chaining has actual effects at runtime and short-circuits to an undefined value if the property you're trying to access does not exist. If you don't know for sure that a property exists, …

  9. Optional Chaining in JavaScript returns undefined instead of null when ...

    Apr 10, 2022 · So, I am reading optional chaining in JavaScript and a question popped into my head. Consider the code below: let person = null let street = person?.street // returns undefined My …

  10. Why doesn't the optional chaining operator (?.) work with Javascript ...

    Jun 17, 2023 · Why doesn't the optional chaining operator (?.) work with Javascript assignment? [duplicate] Asked 2 years, 7 months ago Modified 2 years, 7 months ago Viewed 888 times