Skip to main content

Variables

You can define variable and constant in this way:

With Typescript you can use the keyword let for a variable, for example, let x = 10; You can also define a variable without a keyword, for example, x = 10; Lastly, for constants, you can use keyword const, for example, const x = 10.

There is also the var declaration if you want to declare a variable globally, or locally to a function. let allows you to limit the variables to the scope of a block statement. Not using any declaration gives it complete global access.