Skip to content

馃摑 Article: the difference between optional chaining and non-null assertions聽#69

Open

Description

@JoshuaKGoldberg

Overview

?. and !. aren't the same. I should write an article explaining the difference.

One common slipup I've seen is people doing this:

const myValue = document.getElementById(someId)?.textContent;

...and wondering why myValue is string | undefined, not string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

type: articleAdding a new article .mdx file

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions