0

My question is, Is this a correct validation? And if it is, then what is the name of the type of validation?

I tried to use this and it doesn't work:

const existsProperty = data?.author

Also, I tried this validation and it works, what is the name of this type of validation?

const existsProperty = !!data.author
Abhishek Duppati
  • 554
  • 5
  • 18
Berzavlu
  • 1
  • 1
  • ```const existsProperty = data?.author !== undefined;```, If ```author``` not exists then it will returns ```undefined```. – Sajeeb Ahamed Apr 24 '20 at 19:23
  • thanks i found the answer https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining – Berzavlu Apr 24 '20 at 19:26

0 Answers0