嘗試從都市叢林回到魔法森林。 更多作品 | https://linktr.ee/monles
Javascript — 第02天
- 直譯語言 === 動態語言(e.g. Javascript)
- 編譯語言===靜態(e.g. C語言)
執行環境(Execution Context)
這是有關JS怎麼被執行。 Execution Context是JS環境的抽象概念,環境可以處理JS程式碼的執行和轉換。
這是JS中,兩種Execution Context的種類:
- 全域 Execution Context (GEC)
- 函式 Execution Context (FEC)
more info |
JavaScript Execution Context — How JS Works Behind The Scenes
All JavaScript code needs to be hosted and run in some kind of environment. In most cases, that environment would be a…www.freecodecamp.org
var/let/const
變數提升(Variable hoisting)為var特性, let
和 const
則以「區域」為其作用域。
更多看這裡❤️
Lexical Environment
在JS內部引擎建構識別符-變數(identifier-variable) mappng。
如More info所連結的網站,這個概念表現出code在哪個位置。
More info |
https://ithelp.ithome.com.tw/articles/10192743
Lexical Scope ( 語法作用域)
簡單概念可以這麼形容,函式創造了一個區塊,就像結界一樣,裏頭的變數宣告不會被外部引用,但區塊外部的變數可被函式內部引用。
Lexical scope |
https://ithelp.ithome.com.tw/articles/10194745
提升(Hoisting)
它是一種釐清 JaveScript 在執行階段內文如何運行的思路(尤其是在創建和執行階段)。
變數和函數的宣告會在編譯階段就被放入記憶體,但實際位置和程式碼中完全一樣。
Really good article |
https://developer.mozilla.org/zh-TW/docs/Glossary/Hoisting
函式表達式Function expression
箭頭函式 在ES6中被介紹。
var greenland = () => { console.log(‘cold’) }
or
var greenland = function() { console.log(‘cold’) }
函式宣告(Function Declaration)
function taiwan() { console.log(‘hot’) }
more info |
https://www.casper.tw/javascript/2017/12/16/javascript-hoisting/
函式呼叫/call/執行
Function Invocation/Call/Execution
在JavaScript中,function也可以被定義成為object method,當某些東西invokes它,在JS函式裡的程式碼會被執行。
more info |
https://www.w3schools.com/js/js_function_invocation.asp
V8 引擎如何改善JS
- eval()
- arguments()
- for in
Arguments
arguments
物件是一個對應傳入函式之引數的類陣列(Array-like
)物件。
more info |
https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Functions/arguments
喜欢我的文章吗?
别忘了给点支持与赞赏,让我知道创作的路上有你陪伴。
发布评论…