Skip to content

Commit

Permalink
Merge pull request #97 from GuoXiCheng/dev-c
Browse files Browse the repository at this point in the history
add sparse-array md
  • Loading branch information
GuoXiCheng authored Jul 13, 2024
2 parents 8601e45 + 874005a commit cc2f84a
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 45 deletions.
11 changes: 11 additions & 0 deletions src/.vitepress/sidebars/ecma-script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions src/frontend/vue/introduction/what-is-vue.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# 什么是 Vue

## Vue 是什么
Expand Down
4 changes: 0 additions & 4 deletions src/javascript/bom/history.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# history 对象

## 什么是 history 对象
Expand Down
4 changes: 0 additions & 4 deletions src/javascript/bom/screen.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# screen 对象

## 什么是 screen 对象
Expand Down
4 changes: 0 additions & 4 deletions src/javascript/bom/what-is-bom.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# 什么是 BOM

BOM 的全称是“浏览器对象模型”,通常用来描述浏览器提供的对象,允许开发中与浏览器窗口进行交互。
Expand Down
4 changes: 0 additions & 4 deletions src/javascript/dom/node-hierarchy.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# 节点层级

## 什么是节点层级
Expand Down
4 changes: 0 additions & 4 deletions src/javascript/dom/what-is-dom.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# 什么是 DOM

DOM 的全称是“文档对象模型”,它是 HTML 和 XML 文档的编程接口。
Expand Down
Original file line number Diff line number Diff line change
@@ -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
4 changes: 0 additions & 4 deletions src/javascript/ecma-script/module/module-before-es6/amd.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# AMD

AMD(Asynchronous Module Definition)是一种异步模块定义规范,它以浏览器为目标执行环境。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# CommonJS

CommonJS 规范以同步方式声明依赖的模块,主要用于服务器端实现模块化,也可用于浏览器环境,但不能在浏览器环境中直接运行。
Expand Down
4 changes: 0 additions & 4 deletions src/javascript/ecma-script/module/module-before-es6/iife.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# IIFE

为了提供必要的封装和隔离,ES6 之前的模块会使用立即调用函数表达式(IIFE)将模块的定义封装在匿名闭包中来实现模块模式。
Expand Down
4 changes: 0 additions & 4 deletions src/javascript/ecma-script/module/module-before-es6/umd.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# UMD

UMD(Universal Module Definition)是一种通用模块定义规范,它是为了统一 CommonJS 和 AMD 两种模块定义规范而设计的。
Expand Down
4 changes: 0 additions & 4 deletions src/javascript/ecma-script/module/understand-module.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
aside: false
---

# 理解模块

## 理解模块模式
Expand Down
1 change: 0 additions & 1 deletion src/public/248baafb4b5d06ca6392b897e527aaad.txt

This file was deleted.

0 comments on commit cc2f84a

Please sign in to comment.