added Typescript and Javascript examples in data_and_memory.md

This commit is contained in:
steak-zhuo 2023-01-14 13:54:22 +08:00
parent 7a53f1d082
commit eb3f1b61a6

View file

@ -84,13 +84,19 @@ comments: true
=== "JavaScript"
```js title=""
// JavaScript 的数组可以自由存储各种基本数据类型和对象
// JavaScript 的基本数据类型中只有数字, 没有浮点数, 这里使用0.1作为示例
const array = [0, 0.1, 'a', false]
```
=== "TypeScript"
```typescript title=""
// TypeScript 可以定义 JavaScript 数组的类型
const numbers: number = new Array(5).fill(0);
const decimals: number = new Array(5).fill(0.1);
const characters: string = new Array(5).fill('a');
const booleans: boolean = new Array(5).fill(true);
```
=== "C"