官术网_书友最值得收藏!

Writing JavaScript code with static types

The first thing that you'll notice when working with TypeScript are its static types, in addition to all of the JavaScript types, indicated on the following table:

   
Primitives            Objects
String            Function
Number            Array
Null            Prototypes
Undefined           
Boolean           
Symbol           

 

This means that you can declare the types of variables; it's pretty simple to assign a type to a variable. Let's look at some examples, using JavaScript types only:


function Myband () {
let band: string;
let active: boolean;
let numberOfAlbuns: number;
}

With TypeScript, we have a few more types, as we'll see in the following sections.

主站蜘蛛池模板: 遵义市| 宜兰市| 张家川| 青岛市| 焦作市| 南通市| 平泉县| 南城县| 稷山县| 收藏| 南川市| 汉川市| 绍兴市| 青海省| 永安市| 白河县| 郓城县| 基隆市| 龙门县| 湟源县| 乌审旗| 泸溪县| 武义县| 清远市| 精河县| 利辛县| 沅陵县| 桐梓县| 崇州市| 武鸣县| 始兴县| 锦屏县| 合阳县| 杭锦后旗| 盘山县| 胶州市| 铜陵市| 清丰县| 汪清县| 冀州市| 开鲁县|