JS - Function and Scope
前言 .
- function的基本概念。
- Scope and closure。
- Lexical and dynamic scope。
- function and block scope。
- hosting and closure。
- Pass value。
一 Function的基本概念
(一) . Function的基本概念
1. 函式是JS中的物件。
- 這個概念在JS中很重要,尤其會應用於Object的prototype-base的OOP上。
- 其實,JS中,除了原生型別的變數型態,都應該是屬於『object』,其中,最大的不同是傳值方式。
2. 宣告法一
3. 宣告法二 : 運算式
4. 宣告法三 : 箭頭函式
二 . Scope
(一) . Scope
1 . Scope的定義
- 定義 : 是Js的『engine』搜尋變數是否存在的一種方法。
- Engine : JS語言處理程式碼的核心之一。
- JS處理程式碼的方法 :