diff --git a/src/.vitepress/sidebars/ecma-script.yaml b/src/.vitepress/sidebars/ecma-script.yaml index 685b196..c4c6776 100644 --- a/src/.vitepress/sidebars/ecma-script.yaml +++ b/src/.vitepress/sidebars/ecma-script.yaml @@ -94,6 +94,17 @@ link: /javascript/ecma-script/collection-reference/array/flatten-array - text: 切片或连接数组 link: /javascript/ecma-script/collection-reference/array/slice-or-concat-array + - text: 稀疏数组 + link: /javascript/ecma-script/collection-reference/array/sparse-array + items: + - text: 什么是稀疏数组 + link: /javascript/ecma-script/collection-reference/array/sparse-array#什么是稀疏数组 + - text: 创建稀疏数组 + link: /javascript/ecma-script/collection-reference/array/sparse-array#创建稀疏数组 + - text: 检查稀疏数组 + link: /javascript/ecma-script/collection-reference/array/sparse-array#检查稀疏数组 + - text: 遍历稀疏数组 + link: /javascript/ecma-script/collection-reference/array/sparse-array#遍历稀疏数组 - text: Map link: /javascript/ecma-script/collection-reference/map - text: Set diff --git a/src/frontend/vue/introduction/what-is-vue.md b/src/frontend/vue/introduction/what-is-vue.md index 840b6ef..f49eda4 100644 --- a/src/frontend/vue/introduction/what-is-vue.md +++ b/src/frontend/vue/introduction/what-is-vue.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # 什么是 Vue ## Vue 是什么 diff --git a/src/javascript/bom/history.md b/src/javascript/bom/history.md index b7e46ca..dc7bc0f 100644 --- a/src/javascript/bom/history.md +++ b/src/javascript/bom/history.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # history 对象 ## 什么是 history 对象 diff --git a/src/javascript/bom/screen.md b/src/javascript/bom/screen.md index 2d84cb2..87441ba 100644 --- a/src/javascript/bom/screen.md +++ b/src/javascript/bom/screen.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # screen 对象 ## 什么是 screen 对象 diff --git a/src/javascript/bom/what-is-bom.md b/src/javascript/bom/what-is-bom.md index 3fb9824..9cc5adb 100644 --- a/src/javascript/bom/what-is-bom.md +++ b/src/javascript/bom/what-is-bom.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # 什么是 BOM BOM 的全称是“浏览器对象模型”,通常用来描述浏览器提供的对象,允许开发中与浏览器窗口进行交互。 diff --git a/src/javascript/dom/node-hierarchy.md b/src/javascript/dom/node-hierarchy.md index bd5f3fe..1ae81b1 100644 --- a/src/javascript/dom/node-hierarchy.md +++ b/src/javascript/dom/node-hierarchy.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # 节点层级 ## 什么是节点层级 diff --git a/src/javascript/dom/what-is-dom.md b/src/javascript/dom/what-is-dom.md index fde31c9..7bc754d 100644 --- a/src/javascript/dom/what-is-dom.md +++ b/src/javascript/dom/what-is-dom.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # 什么是 DOM DOM 的全称是“文档对象模型”,它是 HTML 和 XML 文档的编程接口。 diff --git a/src/javascript/ecma-script/collection-reference/array/sparse-array.md b/src/javascript/ecma-script/collection-reference/array/sparse-array.md new file mode 100644 index 0000000..8849015 --- /dev/null +++ b/src/javascript/ecma-script/collection-reference/array/sparse-array.md @@ -0,0 +1,31 @@ +# 稀疏数组 + +## 什么是稀疏数组 + +数组中某些索引没有分配值的数组称为稀疏数组。稀疏数组的长度大于其元素的个数。 + +::: details 稀疏数组与密集数组的区别 +稀疏数组的一个特点是数组的某些索引没有分配值,因此即使数组的每个索引都被复制为 `null` 或 `undefined`,这个数组严格意义上也不是稀疏数组。 + +<<< @/../projects/javascript-sandbox/src/array-method/sparse-array.ts#sparse-array-vs-dense-array +::: + +## 创建稀疏数组 + +创建稀疏数组的常用方法是给数组的高位索引赋值。 + +稀疏数组的 `length` 属性计算方式是数组中最大索引值加一,因此稀疏数组中的实际元素个数会小于数组的长度。 + +<<< @/../projects/javascript-sandbox/src/array-method/sparse-array.ts#create-sparse-array + +## 检查稀疏数组 + +可以使用 `in` 或者 `hasOwnProperty` 方法来检查稀疏数组中的索引是否存在。 + +<<< @/../projects/javascript-sandbox/src/array-method/sparse-array.ts#check-sparse-array + +## 遍历稀疏数组 + +`for...in` 和 `forEach` 循环会跳过稀疏数组中的空位,而简单 for 循环和 `for...of` 循环不会。 + +<<< @/../projects/javascript-sandbox/src/array-method/sparse-array.ts#iterate-sparse-array diff --git a/src/javascript/ecma-script/module/module-before-es6/amd.md b/src/javascript/ecma-script/module/module-before-es6/amd.md index 31f6a8c..1100134 100644 --- a/src/javascript/ecma-script/module/module-before-es6/amd.md +++ b/src/javascript/ecma-script/module/module-before-es6/amd.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # AMD AMD(Asynchronous Module Definition)是一种异步模块定义规范,它以浏览器为目标执行环境。 diff --git a/src/javascript/ecma-script/module/module-before-es6/commonjs.md b/src/javascript/ecma-script/module/module-before-es6/commonjs.md index d4f6f01..a5bb6b5 100644 --- a/src/javascript/ecma-script/module/module-before-es6/commonjs.md +++ b/src/javascript/ecma-script/module/module-before-es6/commonjs.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # CommonJS CommonJS 规范以同步方式声明依赖的模块,主要用于服务器端实现模块化,也可用于浏览器环境,但不能在浏览器环境中直接运行。 diff --git a/src/javascript/ecma-script/module/module-before-es6/iife.md b/src/javascript/ecma-script/module/module-before-es6/iife.md index 87506aa..85f3a80 100644 --- a/src/javascript/ecma-script/module/module-before-es6/iife.md +++ b/src/javascript/ecma-script/module/module-before-es6/iife.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # IIFE 为了提供必要的封装和隔离,ES6 之前的模块会使用立即调用函数表达式(IIFE)将模块的定义封装在匿名闭包中来实现模块模式。 diff --git a/src/javascript/ecma-script/module/module-before-es6/umd.md b/src/javascript/ecma-script/module/module-before-es6/umd.md index bc75965..a97db87 100644 --- a/src/javascript/ecma-script/module/module-before-es6/umd.md +++ b/src/javascript/ecma-script/module/module-before-es6/umd.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # UMD UMD(Universal Module Definition)是一种通用模块定义规范,它是为了统一 CommonJS 和 AMD 两种模块定义规范而设计的。 diff --git a/src/javascript/ecma-script/module/understand-module.md b/src/javascript/ecma-script/module/understand-module.md index 96956a3..5e2fbdc 100644 --- a/src/javascript/ecma-script/module/understand-module.md +++ b/src/javascript/ecma-script/module/understand-module.md @@ -1,7 +1,3 @@ ---- -aside: false ---- - # 理解模块 ## 理解模块模式 diff --git a/src/public/248baafb4b5d06ca6392b897e527aaad.txt b/src/public/248baafb4b5d06ca6392b897e527aaad.txt deleted file mode 100644 index 7c5c3b3..0000000 --- a/src/public/248baafb4b5d06ca6392b897e527aaad.txt +++ /dev/null @@ -1 +0,0 @@ -5d55002010fb8f68a36df8d8be93246b4505a97b \ No newline at end of file