Skip to content

Commit

Permalink
Add Optional chaining on an optional function
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Else committed Mar 3, 2020
1 parent 7253877 commit 116c6be
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -773,6 +773,17 @@ const maybeArtistBioElement = album?.["artist"]?.["bio"];
const maybeFirstPreviousAlbum = album?.artist?.previousAlbums?.[0];
```

Optional chaining on an optional function:

```ts
interface OptionalFunction {
bar?: () => number;
}

const foo: OptionalFunction = {};
const bat = foo.bar?.(); // number | undefined
```

# Nullish Coalescing

## `??` “fall Backs” to a Default Value When Dealing with `null` or `undefined`
Expand Down

0 comments on commit 116c6be

Please sign in to comment.