mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-23 03:56:23 +00:00
35 lines
364 B
Markdown
35 lines
364 B
Markdown
|
---
|
||
|
id: 8809980a-615d-453f-bc63-2f890fca03b8
|
||
|
title: TypeScript primitive types
|
||
|
---
|
||
|
|
||
|
# Syntax
|
||
|
|
||
|
## Number
|
||
|
|
||
|
``` typescript
|
||
|
var num: number
|
||
|
num = 123
|
||
|
num = 123.24
|
||
|
num = '123' / Error
|
||
|
```
|
||
|
|
||
|
## String
|
||
|
|
||
|
``` typescript
|
||
|
var str: string
|
||
|
|
||
|
str = '123'
|
||
|
str = 123 // Error
|
||
|
```
|
||
|
|
||
|
## Boolean
|
||
|
|
||
|
``` typescript
|
||
|
var bool: boolean
|
||
|
|
||
|
bool = true
|
||
|
bool = false
|
||
|
bool = 'tralala' // Error
|
||
|
```
|