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

Type Annotation

What does the : operator after a variable name do in TypeScript?

Answer options

  • Creates a comment in the code
  • Assigns a default value
  • Marks the variable as private
  • Defines the variable type (type annotation)

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