Câu hỏi phỏng vấn Typescript
Câu hỏi

List the built-in types in Typescript

Câu trả lời

TypeScript, as a superset of JavaScript, enhances the language by adding static types. These types can be divided into two main categories: primitive (or built-in) types and user-defined types. Here's a comprehensive list of the built-in types in TypeScript:

Primitive Types

  1. boolean: Represents true/false values.
  2. number: Used for both whole numbers and floating-point values.
  3. string: Represents textual data.
  4. bigint: Can represent whole numbers larger than those that the number type can represent.
  5. symbol: Used to create unique identifiers.
  6. null: Represents the absence of any object value.
  7. undefined: Indicates uninitialized variables or properties.
  8. any: A type that can represent any JavaScript value. It is used to opt-in and opt-out of type-checking during compilation.
  9. void: Used for functions that do not return a value.
  10. unknown: Represents any value but requires the developer to perform type-checking before performing operations on values of this type.
  11. never: Represents types of values that never occur, such as the return type of a function that always throws an error.

Utility Types

TypeScript also includes a variety of utility types that allow for more complex type transformations and operations. Some of the key utility types include:

  1. Partial: Creates a type with all properties of T set to optional.
  2. Required: Makes all properties of T required.
  3. Readonly: Makes all properties of T read-only.
  4. **Record<K...
entry

entry

Gợi ý câu hỏi phỏng vấn

junior

How do we create an enum with string values?

senior

Explain what is never datatype in TypeScript?

middle

How to make a readonly tuple type in TypeScript?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào