Search⌘ K

The Bang Operator

Explore the bang operator in TypeScript, which allows you to assert a variable is not null or undefined. Learn when and how to use it safely to avoid runtime errors and improper handling of undefined values in your code.

Bang operator role

The bang operator is the use of the exclamation point symbol !. The operator can be used after a variable and before the dot to access a member.

It is officially called the “non-null assertion operator”. A variable with the value undefined or null can benefit from using the ...