#usage of ! & ? in validation statements.
10 messages · Page 1 of 1 (latest)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining, https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#non-null-assertion-operator-postfix-
The language primitives.
I know null assertion and ternary operator but what is the purpose of using it in this
The optional chaining (?.) operator accesses an object's property or calls a function. If the object is undefined or null, it returns undefined instead of throwing an error.
! is to bypass types that might have undefined or null value.
TypeScript also has a special syntax for removing null and undefined from a type without doing any explicit checking. Writing ! after any expression is effectively a type assertion that the value isn’t null or undefined
Ok thanks for the info.
You can google ! vs ? typescript. Google is your best teacher
You can also just read the links I posted, which have nothing to do with the ternary operator and explain what you asked for.
I just copied and pasted the first lines from each of those links and added bolding. 🙂