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

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.

主站蜘蛛池模板: 昭平县| 朝阳市| 孝昌县| 定襄县| 瓦房店市| 湘潭县| 弥渡县| 逊克县| 永兴县| 邮箱| 尚义县| 年辖:市辖区| 崇阳县| 龙里县| 综艺| 无棣县| 碌曲县| 天祝| 丹江口市| 东丽区| 平潭县| 西贡区| 盐池县| 兴隆县| 明水县| 西乌珠穆沁旗| 日土县| 邮箱| 英山县| 花莲县| 云梦县| 嘉峪关市| 金门县| 久治县| 尼木县| 泰安市| 黎城县| 高州市| 普兰店市| 思茅市| 封丘县|