From eb3f1b61a6ca31a9a0e0b83d5d1e658d70decf6a Mon Sep 17 00:00:00 2001 From: steak-zhuo Date: Sat, 14 Jan 2023 13:54:22 +0800 Subject: [PATCH] added Typescript and Javascript examples in data_and_memory.md --- docs/chapter_data_structure/data_and_memory.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/chapter_data_structure/data_and_memory.md b/docs/chapter_data_structure/data_and_memory.md index 93147fb65..52a666fec 100644 --- a/docs/chapter_data_structure/data_and_memory.md +++ b/docs/chapter_data_structure/data_and_memory.md @@ -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"