Skip to main content
Updated answer following feedback from @altocumulus
Source Link
superluminary
  • 49.6k
  • 26
  • 154
  • 152

The Elvis (?.) operatorOptional Chaining Operator is supported in TypeScript 3.7.

You can use it to check for null values: cats?.miows returns null if cats is null or undefined.

You can also use it for optional method calling: cats.doMiow?.(5) will call doMiow if it exists.

Property access is also possible: cats?.['miows'].

Reference: https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/

The Elvis (?) operator is supported in TypeScript 3.7.

You can use it to check for null values: cats?.miows returns null if cats is null or undefined.

You can also use it for optional method calling: cats.doMiow?(5) will call doMiow if it exists.

Reference: https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/

The Elvis (?.) Optional Chaining Operator is supported in TypeScript 3.7.

You can use it to check for null values: cats?.miows returns null if cats is null or undefined.

You can also use it for optional method calling: cats.doMiow?.(5) will call doMiow if it exists.

Property access is also possible: cats?.['miows'].

Reference: https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/

added 88 characters in body
Source Link
superluminary
  • 49.6k
  • 26
  • 154
  • 152

The Elvis (?) operator is supported in TypeScript 3.7.

You can use it to check for null values: cats?.miows returns null if cats is null or undefined.

You can also use it for optional method calling: cats.doMiow?(5) will call doMiow if it exists.

Reference: https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/

The Elvis (?) operator is supported in TypeScript 3.7.

You can use it to check for null values: cats?.miows returns null if cats is null or undefined.

You can also use it for optional method calling: cats.doMiow?(5) will call doMiow if it exists.

The Elvis (?) operator is supported in TypeScript 3.7.

You can use it to check for null values: cats?.miows returns null if cats is null or undefined.

You can also use it for optional method calling: cats.doMiow?(5) will call doMiow if it exists.

Reference: https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/

Source Link
superluminary
  • 49.6k
  • 26
  • 154
  • 152

The Elvis (?) operator is supported in TypeScript 3.7.

You can use it to check for null values: cats?.miows returns null if cats is null or undefined.

You can also use it for optional method calling: cats.doMiow?(5) will call doMiow if it exists.