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

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.

主站蜘蛛池模板: 确山县| 宁强县| 金山区| 泽库县| 周宁县| 会泽县| 肇州县| 德阳市| 从江县| 晋州市| 灯塔市| 漳平市| 泌阳县| 宁津县| 梓潼县| 汝州市| 霞浦县| 石城县| 绥棱县| 乌拉特前旗| 阆中市| 成武县| 石门县| 勃利县| 灵寿县| 于田县| 天全县| 达拉特旗| 绥芬河市| 呈贡县| 海阳市| 丹东市| 喀什市| 高邮市| 高陵县| 上栗县| 汶川县| 深泽县| 阜南县| 德昌县| 深州市|