0

what is the difference between:

if(object.mydataitem)
{
    //rest of code
}

and

if(object?.mydataitem)
{
    //rest of code
}

I just dont know when to use one of them over the other and what exactly is the functionality of the '?'.

  • This is all in the [documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining). The second will not throw an error if `object` is null or undefined. – trincot Jul 28 '23 at 18:32

0 Answers0