Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

typescript
communitycreator

What are identifiers and keywords in TypeScript?

Chibueze Sam-Obisike

Identifiers

Identifiers are names given to functions, variables, classes, etc., that we can use to refer to them.

In TypeScript, we do not just name variables using any name. Rather, we follow some rules that guide naming in Typescript, which is similar to JavaScript.

The rules for identifiers

  1. Identifiers should not include special symbols except _ or sign, e.g., full_name.
  2. Identifiers are case sensitive.
  3. Identifiers can include digits, but most do not begin with a digit.
  4. Identifiers must not be the reserved keywords used in TypeScript like any or for.
  5. Identifiers must be unique in naming.

Keywords

Keywords are a predefined set of reserved words that have special meaning in a program.

Examples of keywords in Typescript include the following:

break, as, any, switch case , if, throw, else, var, number, string ,get, module, type, instanceof, typeof, public, private, enum, export, finally, for, while, void, null, super, this, new, in, return, true, false, any, extends, static, let, package, implements, interface , function, new, try ,yield, const, continue, do, catch

Many others are words reserved in TypeScript.

Typescript ignores indentation and whitespace. However, you can add them to make your code look more readable.

RELATED TAGS

typescript
communitycreator

CONTRIBUTOR

Chibueze Sam-Obisike
RELATED COURSES

View all Courses

Keep Exploring