預解析、預處理html
1. 在全局代碼執行以前,js 引擎 就會建立一個棧來存儲管理全部的 執行上下文對象數組
2. 在 全局執行上下文 window 肯定之後,進行壓棧安全
3. 在 函數執行上下文對象 肯定之後,進行壓棧函數
4. 當 函數 執行完,進行 出棧 操做this
5. 當全部的代碼執行完之後,棧中只剩下 windowspa
注意: 當棧中含有多個 函數上下文對象 ,則表示當前在執行嵌套函數。prototype
產生的上下文對象 個數 = n + 1個全局上下文對象code
function Person(name,gender,age){ this.name = name; this.gender = gender; this.age = age; this.sayName = function(){ document.write("我叫"+this.name); }; } var ts = new Person("唐僧","男",27); ts.sayName(); // 使用 instanceof 能夠檢查 一個對象是不是某個類的實例 console.log(ts instanceof Person); // 固然返回 true
// xxx instanceof Object 永遠返回 true ,由於全部對象都是 Object 的派生類