# JS QA ###### tags: `JavaScript` ### 什麼是 hoisting? #### execution context - creation phase - global object - this(指向 globa lobject) - outer enviroment - execution phase ```javascript= var a = "global" function hiHoisting(){ // var a -> hoisting! console.log(a) var a = "local" } hiHoisting() // undefind ``` ### function declaration vs function expression 差別? #### - Declaration( = Statements)表達式 #### - Expression 陳述句 不會回傳值,也不能將他命名變數。 指的是輸入後能夠**直接回傳值**的一串程式。 ```javascript= // function Declaration function callTest(){ console.log(123); } callTest(); ``` ```javascript= // function Expression var callTest = function(){ console.log(123); } callTest(); ``` ### By value vs by reference | | Pass By Value | Pass By Reference | | -------- | -------- | -------- | | 說明 | 在記憶體中建立一個新位置,賦予數值。 | 指定到物件到 b 到 a 的位置,取得值。 | | 賦值類別 | Primitive Type 原始型別 | Object Type 物件型別 類別細節 | Boolean, String, Number, null, undefined | Object, Function, Array, Set
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up