Question · JavaScript and TypeScript course · Module 6: TypeScript Basics

The as Operator in TypeScript

What does the as operator do in TypeScript?

Answer options

  • Imports a module under a different name
  • Performs a type assertion - tells the compiler that a value is of a given type
  • Creates an alias for a variable
  • Converts a value to a different type at runtime

You can check the correct answer by solving this task in the CodeWorlds game.