Skip to content

Commit

Permalink
完成 - 基础
Browse files Browse the repository at this point in the history
  • Loading branch information
LiangJunrong committed Oct 12, 2020
1 parent 2075cb3 commit 6c7009c
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
01 - 基础
基础
===

> Create by **jsliang** on **2020-09-07 21:31:37**
> Recently revised in **2020-10-08 12:47:55**
> Recently revised in **2020-10-12 23:15:56**
<!-- 目录开始 -->
## <a name="chapter-one" id="chapter-one"></a>一 目录
Expand All @@ -27,6 +27,9 @@
| <a name="catalog-chapter-ten" id="catalog-chapter-ten"></a>[十 JS 拖拽](#chapter-ten) |
| <a name="catalog-chapter-eleven" id="catalog-chapter-eleven"></a>[十一 setTimeout 实现 setInterval](#chapter-eleven) |
| <a name="catalog-chapter-twelve" id="catalog-chapter-twelve"></a>[十二 实现 Sleep](#chapter-twelve) |
| <a name="catalog-chapter-thirteen" id="catalog-chapter-thirteen"></a>[十三 执行上下文](#chapter-thirteen) |
| &emsp;[13.1 执行上下文类型](#chapter-thirteen-one) |
| &emsp;[13.2 执行栈](#chapter-thirteen-two) |
<!-- 目录结束 -->

## <a name="chapter-two" id="chapter-two"></a>二 前言
Expand Down Expand Up @@ -317,17 +320,23 @@ sleep(1000).then((res) => {
});
```

## 执行上下文
## <a name="chapter-thirteen" id="chapter-thirteen"></a>十三 执行上下文

### 执行上下文类型
> [返回目录](#chapter-one)
### <a name="chapter-thirteen-one" id="chapter-thirteen-one"></a>13.1 执行上下文类型

> [返回目录](#chapter-one)
JavaScript 中有 3 种执行上下文类型:

* **全局执行上下文**:这是默认或者说基础的上下文,任何不在函数内部的代码都在全局上下文中。它会执行两件事:创建一个全局的 `window` 对象(浏览器的情况下),并且设置 `this` 的值等于这个全局对象。一个程序中只会有一个全局执行上下文。
* **函数执行上下文**:每当一个函数被调用时, 都会为该函数创建一个新的上下文。每个函数都有它自己的执行上下文,不过是在函数被调用时创建的。函数上下文可以有任意多个。每当一个新的执行上下文被创建,它会按定义的顺序执行一系列步骤。
* **Eval 函数执行上下文**:执行在 `eval` 函数内部的代码也会有它属于自己的执行上下文,但由于 JavaScript 开发者并不经常使用 `eval`,所以在这里我不会讨论它。

### 执行栈
### <a name="chapter-thirteen-two" id="chapter-thirteen-two"></a>13.2 执行栈

> [返回目录](#chapter-one)
执行栈,也就是在其它编程语言中所说的 “调用栈”,是一种拥有 LIFO(后进先出)数据结构的栈,被用来存储代码运行时创建的所有执行上下文。

Expand Down

0 comments on commit 6c7009c

Please sign in to comment.