Typescript数组文字语法的差异 [英] Differences in Typescript array literal syntax

查看:96
本文介绍了Typescript数组文字语法的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Typescript允许使用以下两种语法定义一个数组:

Typescript allows one to define an Array with either syntax:

var myStrArry1: string[] = [];

var myStrArry1: Array<string> = [];

编译后的输出似乎是相同的.编译器是否将它们等同地对待,还是有一些需要注意的怪癖?

The compiled output appears to be the same. Does the compiler treat them identically, or are there some quirks to be aware of?

推荐答案

编译器是否将它们等同地对待,还是有一些需要注意的怪癖?

Does the compiler treat them identically, or are there some quirks to be aware of?

它们是相同的.我更喜欢语法1

They are identical. I prefer syntax 1

这篇关于Typescript数组文字语法的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆