Skip to main content

Posts

Showing posts with the label How to Declare Variable in TypeScript?

What is Variable in TypeScript? How to Declare Variable in TypeScript?

The variable is simply a name of storage location and all variables must be identified with unique names and these unique names are called identifiers. Note –   I am using the “ let ” keyword instead of “ var ” keyword. The “ let ” keyword is actually a newer JavaScript construct that TypeScript makes available. Actually, many common problems in JavaScript are reducing by using “ let ” keyword. So we should use “ let ” keyword instead of “ var ” keyword. Stayed Informed – Learn Angular 2 A variable contains values such as "Hi" or 22. When you use the variable, you refer to the data it represents. For example – let name: string = "Hi" ; //var name: string = "Anil Singh"; let num: number = 22; //var num: number = 22; There are some rules while declaring variables i.e. 1.      The variable names must begin with a letter 2.      The variable names can contain letters, digits, underscores, and dollar signs. 3...