-2

What does "?." means after a function? As after i

const user = () => { query.fetch(data); // anything here} but we are getting to access it like user?.name... what does ?. means

const user = () => { query.fetch(data); // anything here}

  • It's the [optional chaining operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining). – D M Jan 04 '23 at 17:36

1 Answers1

0

The optional chaining (?.) operator accesses an object's property or calls a function. If the object accessed or function called is undefined or null, it returns undefined instead of throwing an error.

rami atallah
  • 104
  • 5