728x90

In Typescript, the exclamtion is sometimes used in last of the characters.

For example,

const people = { name: 'kim' };

if (people.name!) {
  ...
}

what is meaning?

In TypeScript, the exclamation mark (!) is used to assert that a value is not null or undefined. It is called the non-null assertion operator. However, it is typically used when you are certain that the value will not be null or undefined, and it should be used with caution.

728x90
반응형

'개발, 코딩 > typescript' 카테고리의 다른 글

typescript, 제네릭에대해 알아보자  (0) 2022.11.10
optional과 undefined의 차이  (0) 2022.10.26
typescript, 타입 소개  (0) 2022.10.26