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

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.

主站蜘蛛池模板: 全州县| 康马县| 鄱阳县| 新竹县| 疏附县| 格尔木市| 辽阳县| 会宁县| 巧家县| 雅江县| 孟州市| 聊城市| 三都| 蕉岭县| 平乡县| 茶陵县| 淮阳县| 大丰市| 加查县| 宿迁市| 汝城县| 岑巩县| 金乡县| 闻喜县| 阳朔县| 平泉县| 政和县| 聂荣县| 榆社县| 孝昌县| 林芝县| 台江县| 贡嘎县| 阳山县| 聂荣县| 大渡口区| 互助| 桦南县| 崇左市| 宾阳县| 庆元县|