為了提高 Javascript 在瀏覽器上的效能, Javascript 編譯器會進行名為 Hoisting(提升)的行為,當 JS engine對 Javascript 進行編譯時會同時進行變數及函式的宣告,將他們儲存在記憶體中,然後運行被編譯過的代碼。
sayHi();
function sayHi() {
console.log(words); // undefined
var words = 'Hello';
許多 Javascript 開發者努力編寫可讀性高、維護性高且復用性高的 Javascript 代碼,因為要寫出糟糕的 Javascript 代碼非常簡單。設計模型幫助我們結構與組織我們的 Javascript 代碼。每個設計模型都包含許多特性,了解各個設計模型能幫助我們寫出優雅的程式代碼。
設計模型是被驗證過的,它已經事先幫解決一些我們可能會遇到的問題。
Gang of Four(有關於設計模型的書) 一書中沒有提及 Constructor Pattern,但我們在 Javascript 中建立一個新的物件時,Constructor Pattern 是很重要的概念。
超簡單!十分鐘打造漂亮又好用的 zsh command line 環境
"terminal.integrated.fontFamily": "SauceCodePro Nerd Font"
// 以下用簡單的程式碼說明 Redux | |
/* | |
* 核心概念 | |
* | |
* 1. 只使用一個 store 將整個應用程式的狀態 (state) 用物件樹 (object tree) 的方式儲存起來。 | |
* | |
* 2. 唯一可以改變這個 state 的方法就是發送 action,這個 action 其實就只是一個物件告訴 state 該怎麼改變而已。 | |
* | |
* 3. 實際因應 action 裡的內容對 state 做變化的函式叫做 reducer。 |
git rm -r --cached . | |
git add . | |
git commit -m "fixing .gitignore" |
function redirect() { | |
res.writeHead({ location: 'https://www.example.org/' }); | |
res.end(); | |
} |
Start MongoDB without access control.
$ systemctl start mongod