当前位置:网站首页>Basic type variable declaration
Basic type variable declaration
2022-06-29 13:37:00 【Bean paste,】
One , Preface
1. be relative to javascript,typescript One of the characteristics of can Declare variables with data types .
2. When a variable with a confirmed data type is assigned a value of a different type , It will be wrong when compiling , To some extent, it can typescript Understood as strongly typed javascript
Two , The form of the statement
1.let [ Variable name ] : [ type ] = value perhaps let [ Variable name ] : [ type ]
let a:number = 10
let b:string
2. Declare the type of the variable , But there is no initial value , The variable value will be set to undefined
3、 ... and , Legal base types
1. Any type :any
let a:any = 'hello world'
a = 123 // If the assignment is of different types, no error will be reported
2. Numeric type :number
let a:number = 123
let b:number = 0b1010
3. String type :string
let a:string = "123"
4. Boolean type :boolean
let a:boolean = true
5. An array type :[ type ][] || Array< type >
let a:any[] = [1,"2",true]
let b:Array<number> = [1, 2, 3]
6. object type :object
let a:object = [1,"2",true]
let b:object = {
a:1}
7.null and undefined, stay ts in ,undefined and null They have their own types called undefined and null, It's not very useful in itself
let a:undefined = undefined
let b:null = null
8. Tuples
9. enumeration
10.void
边栏推荐
- The imshow function of Matplotlib displays grayscale images. Vmin and vmax2 parameters should be set
- 3个最佳实践助力企业改善供应链安全
- Cvpr2022 𞓜 thin domain adaptation
- PG基础篇--逻辑结构管理(1)
- Is it safe to open an account online?
- Huawei machine learning service speech recognition function enables applications to paint "sound" and color
- 神经网络各个部分的作用 & 彻底理解神经网络
- Memorized Function
- 请问老师炒期货怎么设定安全线和安全边际?
- How can the sports app keep the end-to-side background alive to make the sports record more complete?
猜你喜欢

Imile uses Zadig's multi cloud environment to deploy thousands of times a week to continuously deliver global business across clouds and regions

Tutorial on building pytoch model from zero (IV) compiling training process -- Parameter Analysis

云原生(三十一) | Kubernetes篇之Kubernetes平台基本预装资源
![[untitled] error in installation dependency: refusing to install package with name](/img/53/8c871037b7586343fd509dcecb0d96.png)
[untitled] error in installation dependency: refusing to install package with name "* * *" under a package

Want to make a wechat game for answering questions? Reading this article is enough

System. Currenttimemillis() and system Nanotime() which is faster? Most people get the wrong answer!

Why is the integration of storage and computing a new direction of core making Collision school x Zhicun Technology

Pod security policy (PSP)

自主可控再下一城!首套国产ARTIQ架构量子计算测控系统发布

Autonomous and controllable city! Release of the first domestic artiq architecture quantum computing measurement and control system
随机推荐
How to set the safety line and safety margin for futures trading?
服务器上的RTC时间与世界时间不一致解决办法
matplotlib的imshow函数显示灰度图像要设置vmin和vmax2个参数
Win32 Tetris (essential for learning MFC)
System.currentTimeMillis() 和 System.nanoTime() 哪个更快?大部分人都会答错!
Summary of common MySQL statements and commands
项目管理复习题
C language simulation to realize all character functions
CVPR2022 | 重新审视池化:你的感受野不是最理想的
Weserver Publishing Map Service
Redis deletion policy and eviction algorithm
Pod security policy (PSP)
Create an API rapid development platform, awesome!
神经网络各个部分的作用 & 彻底理解神经网络
安装terraform-ovirt插件为ovirt提供自动化管理
极光 · 哈夫曼树の生成(线段树结构 非指针)(仿邻接表)
CVPR2022 | 可精简域适应
Don't build the wheel again. It is recommended to use Google guava open source tool class library. It is really powerful!
Exploring the way of automated testing - Preparation
[system design] proximity service