{"id":2727,"date":"2020-04-16T16:33:37","date_gmt":"2020-04-16T08:33:37","guid":{"rendered":"http:\/\/www.yuguoxy.com\/geekhome\/?p=2727"},"modified":"2026-08-18T12:35:29","modified_gmt":"2026-08-18T04:35:29","slug":"%e5%89%8d%e7%ab%afjs%e7%9b%b8%e5%85%b3%e7%9f%a5%e8%af%86","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=2727","title":{"rendered":"\u524d\u7aefjavascript\u9ad8\u7ea7"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\">\u8fd9\u7bc7\u4ece <strong style=\"color: #4870ac;\">JS \u57fa\u7840<\/strong>\u3001\u9762\u5411\u5bf9\u8c61\u548c <strong style=\"color: #4870ac;\">V8<\/strong> \u4e09\u4e2a\u65b9\u5411\u6536\u524d\u7aef\u8fdb\u9636\uff1aES5 \u6a21\u62df let\/const\uff0c\u624b\u5199 call\/apply\/bind\u3001\u9632\u6296\u8282\u6d41\u3001\u6241\u5e73\u5316\u3001Promise\uff0c\u518d\u5199 new \u4e0e\u56db\u79cd\u7ee7\u627f\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u914d\u56fe\u548c\u8868\u683c\u6309\u539f\u6587\u4fdd\u7559\u3002\u6700\u540e\u7528\u5f15\u7528\u8ba1\u6570\u3001\u6807\u8bb0\u6e05\u9664\u548c V8 \u7684\u7f16\u8bd1\u4f18\u5316\u89e3\u91ca JS \u4e3a\u4ec0\u4e48\u6bd4 C++ \u6162\u3001\u5f15\u64ce\u505a\u4e86\u4ec0\u4e48\u3002<\/p>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u677f\u5757<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u8981\u80fd\u624b\u5199 \/ \u8bb2\u6e05<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">JS \u57fa\u7840<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">let\/const\u3001call\/apply\/bind\u3001\u9632\u6296\u8282\u6d41\u3001\u6241\u5e73\u5316\u3001Promise<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u9762\u5411\u5bf9\u8c61<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6a21\u62df new\u3001\u539f\u578b\u94fe \/ \u6784\u9020 \/ \u7ec4\u5408 \/ \u5bc4\u751f\u7ec4\u5408\u7ee7\u627f<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">V8<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6267\u884c\u6d41\u7a0b\u3001\u5f15\u7528\u8ba1\u6570\u4e0e\u6807\u8bb0\u6e05\u9664\u3001\u5206\u4ee3 GC\u3001\u4f18\u5316\u624b\u6bb5<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u672c\u6587\u5c06\u4ece\u4ee5\u4e0b\u5341\u4e00\u4e2a\u7ef4\u5ea6\u4e3a\u8bfb\u8005\u603b\u7ed3\u524d\u7aef\u57fa\u7840\u77e5\u8bc6\n<\/p><\/blockquote>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/17150295c4bb639b.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-2729\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/17150295c4bb639b.png\" alt=\"17150295c4bb639b\" width=\"1127\" height=\"998\" \/><\/a><br \/>\n<a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/aa.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2741\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/aa.png\" alt=\"aa\" width=\"280\" height=\"630\" \/><\/a><\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">JS\u57fa\u7840<\/h2>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">1. \u5982\u4f55\u5728ES5\u73af\u5883\u4e0b\u5b9e\u73b0let<\/h3>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u5bf9\u4e8e\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u67e5\u770b<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">babel<\/code>\u8f6c\u6362\u524d\u540e\u7684\u7ed3\u679c\uff0c\u770b\u4e00\u4e0b\u5728\u5faa\u73af\u4e2d\u901a\u8fc7<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">let<\/code>\u5b9a\u4e49\u7684\u53d8\u91cf\u662f\u5982\u4f55\u89e3\u51b3\u53d8\u91cf\u63d0\u5347\u7684\u95ee\u9898\n<\/p><\/blockquote>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1714616e2fd53bf8.jpg\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-2730\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1714616e2fd53bf8.jpg\" alt=\"1714616e2fd53bf8\" width=\"1312\" height=\"419\" \/><\/a><\/p>\n<p style=\"margin: 1em 0px;\">babel\u5728let\u5b9a\u4e49\u7684\u53d8\u91cf\u524d\u52a0\u4e86\u9053\u4e0b\u5212\u7ebf\uff0c\u907f\u514d\u5728\u5757\u7ea7\u4f5c\u7528\u57df\u5916\u8bbf\u95ee\u5230\u8be5\u53d8\u91cf\uff0c\u9664\u4e86\u5bf9\u53d8\u91cf\u540d\u7684\u8f6c\u6362\uff0c\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7\u81ea\u6267\u884c\u51fd\u6570\u6765\u6a21\u62df\u5757\u7ea7\u4f5c\u7528\u57df<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">(function(){\n  for(var i = 0; i &lt; 5; i ++){\n    console.log(i)  \/\/ 0 1 2 3 4\n  }\n})();\n\nconsole.log(i)      \/\/ Uncaught ReferenceError: i is not defined\n\n<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">2. \u5982\u4f55\u5728ES5\u73af\u5883\u4e0b\u5b9e\u73b0const<\/h3>\n<p style=\"margin: 1em 0px;\">\u5b9e\u73b0const\u7684\u5173\u952e\u5728\u4e8e<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">Object.defineProperty()<\/code>\u8fd9\u4e2aAPI\uff0c\u8fd9\u4e2aAPI\u7528\u4e8e\u5728\u4e00\u4e2a\u5bf9\u8c61\u4e0a\u589e\u52a0\u6216\u4fee\u6539\u5c5e\u6027\u3002\u901a\u8fc7\u914d\u7f6e\u5c5e\u6027\u63cf\u8ff0\u7b26\uff0c\u53ef\u4ee5\u7cbe\u786e\u5730\u63a7\u5236\u5c5e\u6027\u884c\u4e3a\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">Object.defineProperty()<\/code> \u63a5\u6536\u4e09\u4e2a\u53c2\u6570\uff1a<\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\nObject.defineProperty(obj, prop, desc)\n<\/p><\/blockquote>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u53c2\u6570<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">obj<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u8981\u5728\u5176\u4e0a\u5b9a\u4e49\u5c5e\u6027\u7684\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">prop<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u8981\u5b9a\u4e49\u6216\u4fee\u6539\u7684\u5c5e\u6027\u7684\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">descriptor<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5c06\u88ab\u5b9a\u4e49\u6216\u4fee\u6539\u7684\u5c5e\u6027\u63cf\u8ff0\u7b26<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u5c5e\u6027\u63cf\u8ff0\u7b26<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u8bf4\u660e<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u9ed8\u8ba4\u503c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">value<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u8be5\u5c5e\u6027\u5bf9\u5e94\u7684\u503c\u3002\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684 JavaScript \u503c\uff08\u6570\u503c\uff0c\u5bf9\u8c61\uff0c\u51fd\u6570\u7b49\uff09\u3002\u9ed8\u8ba4\u4e3a undefined<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">undefined<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">get<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u4e00\u4e2a\u7ed9\u5c5e\u6027\u63d0\u4f9b getter \u7684\u65b9\u6cd5\uff0c\u5982\u679c\u6ca1\u6709 getter \u5219\u4e3a undefined<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">undefined<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">set<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u4e00\u4e2a\u7ed9\u5c5e\u6027\u63d0\u4f9b setter \u7684\u65b9\u6cd5\uff0c\u5982\u679c\u6ca1\u6709 setter \u5219\u4e3a undefined\u3002\u5f53\u5c5e\u6027\u503c\u4fee\u6539\u65f6\uff0c\u89e6\u53d1\u6267\u884c\u8be5\u65b9\u6cd5<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">undefined<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">writable<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5f53\u4e14\u4ec5\u5f53\u8be5\u5c5e\u6027\u7684writable\u4e3atrue\u65f6\uff0cvalue\u624d\u80fd\u88ab\u8d4b\u503c\u8fd0\u7b97\u7b26\u6539\u53d8\u3002\u9ed8\u8ba4\u4e3a false<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">false<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">enumerable<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">enumerable\u5b9a\u4e49\u4e86\u5bf9\u8c61\u7684\u5c5e\u6027\u662f\u5426\u53ef\u4ee5\u5728 for&#8230;in \u5faa\u73af\u548c Object.keys() \u4e2d\u88ab\u679a\u4e3e<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">false<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">Configurable<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">configurable\u7279\u6027\u8868\u793a\u5bf9\u8c61\u7684\u5c5e\u6027\u662f\u5426\u53ef\u4ee5\u88ab\u5220\u9664\uff0c\u4ee5\u53ca\u9664value\u548cwritable\u7279\u6027\u5916\u7684\u5176\u4ed6\u7279\u6027\u662f\u5426\u53ef\u4ee5\u88ab\u4fee\u6539<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">false<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin: 1em 0px;\">\u5bf9\u4e8econst\u4e0d\u53ef\u4fee\u6539\u7684\u7279\u6027\uff0c\u6211\u4eec\u901a\u8fc7\u8bbe\u7f6ewritable\u5c5e\u6027\u6765\u5b9e\u73b0<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">function _const(key, value) {    \n    const desc = {        \n        value,        \n        writable: false    \n    }    \n    Object.defineProperty(window, key, desc)\n}\n    \n_const('obj', {a: 1})   \/\/\u5b9a\u4e49obj\nobj.b = 2               \/\/\u53ef\u4ee5\u6b63\u5e38\u7ed9obj\u7684\u5c5e\u6027\u8d4b\u503c\nobj = {}                \/\/\u629b\u51fa\u9519\u8bef\uff0c\u63d0\u793a\u5bf9\u8c61read-only\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u53c2\u8003\u8d44\u6599\uff1a<a href=\"https:\/\/juejin.im\/post\/5ce3b2d451882533287a767f\">\u5982\u4f55\u5728 ES5 \u73af\u5883\u4e0b\u5b9e\u73b0\u4e00\u4e2aconst \uff1f<\/a><\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">3. \u624b\u5199call()<\/h3>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">call() \u65b9\u6cd5`\u4f7f\u7528\u4e00\u4e2a\u6307\u5b9a\u7684 this \u503c\u548c\u5355\u72ec\u7ed9\u51fa\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u53c2\u6570\u6765\u8c03\u7528\u4e00\u4e2a\u51fd\u6570\n\u8bed\u6cd5\uff1a`function.call(thisArg, arg1, arg2, ...)\n<\/code><\/pre>\n<\/blockquote>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">call()<\/code>\u7684\u539f\u7406\u6bd4\u8f83\u7b80\u5355\uff0c\u7531\u4e8e\u51fd\u6570\u7684this\u6307\u5411\u5b83\u7684\u76f4\u63a5\u8c03\u7528\u8005\uff0c\u6211\u4eec\u53d8\u66f4\u8c03\u7528\u8005\u5373\u5b8c\u6210this\u6307\u5411\u7684\u53d8\u66f4\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/\u53d8\u66f4\u51fd\u6570\u8c03\u7528\u8005\u793a\u4f8b\nfunction foo() {\n    console.log(this.name)\n}\n\n\/\/ \u6d4b\u8bd5\nconst obj = {\n    name: '\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb'\n}\nobj.foo = foo   \/\/ \u53d8\u66f4foo\u7684\u8c03\u7528\u8005\nobj.foo()       \/\/ '\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb'\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u57fa\u4e8e\u4ee5\u4e0a\u539f\u7406, \u6211\u4eec\u4e24\u53e5\u4ee3\u7801\u5c31\u80fd\u5b9e\u73b0call()<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">Function.prototype.myCall = function(thisArg, ...args) {\n    thisArg.fn = this              \/\/ this\u6307\u5411\u8c03\u7528call\u7684\u5bf9\u8c61,\u5373\u6211\u4eec\u8981\u6539\u53d8this\u6307\u5411\u7684\u51fd\u6570\n    return thisArg.fn(...args)     \/\/ \u6267\u884c\u51fd\u6570\u5e76return\u5176\u6267\u884c\u7ed3\u679c\n}\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4f46\u662f\u6211\u4eec\u6709\u4e00\u4e9b\u7ec6\u8282\u9700\u8981\u5904\u7406\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">Function.prototype.myCall = function(thisArg, ...args) {\n    const fn = Symbol('fn')        \/\/ \u58f0\u660e\u4e00\u4e2a\u72ec\u6709\u7684Symbol\u5c5e\u6027, \u9632\u6b62fn\u8986\u76d6\u5df2\u6709\u5c5e\u6027\n    thisArg = thisArg || window    \/\/ \u82e5\u6ca1\u6709\u4f20\u5165this, \u9ed8\u8ba4\u7ed1\u5b9awindow\u5bf9\u8c61\n    thisArg[fn] = this              \/\/ this\u6307\u5411\u8c03\u7528call\u7684\u5bf9\u8c61,\u5373\u6211\u4eec\u8981\u6539\u53d8this\u6307\u5411\u7684\u51fd\u6570\n    const result = thisArg[fn](...args)  \/\/ \u6267\u884c\u5f53\u524d\u51fd\u6570\n    delete thisArg[fn]              \/\/ \u5220\u9664\u6211\u4eec\u58f0\u660e\u7684fn\u5c5e\u6027\n    return result                  \/\/ \u8fd4\u56de\u51fd\u6570\u6267\u884c\u7ed3\u679c\n}\n\n\/\/\u6d4b\u8bd5\nfoo.myCall(obj)     \/\/ \u8f93\u51fa'\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb'\n\n<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">4. \u624b\u5199apply()<\/h3>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\napply() \u65b9\u6cd5\u8c03\u7528\u4e00\u4e2a\u5177\u6709\u7ed9\u5b9athis\u503c\u7684\u51fd\u6570\uff0c\u4ee5\u53ca\u4f5c\u4e3a\u4e00\u4e2a\u6570\u7ec4\uff08\u6216\u7c7b\u4f3c\u6570\u7ec4\u5bf9\u8c61\uff09\u63d0\u4f9b\u7684\u53c2\u6570\u3002<br \/>\n\u8bed\u6cd5\uff1afunc.apply(thisArg, [argsArray])\n<\/p><\/blockquote>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">apply()<\/code>\u548c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">call()<\/code>\u7c7b\u4f3c\uff0c\u533a\u522b\u5728\u4e8ecall()\u63a5\u6536\u53c2\u6570\u5217\u8868\uff0c\u800capply()\u63a5\u6536\u4e00\u4e2a\u53c2\u6570\u6570\u7ec4\uff0c\u6240\u4ee5\u6211\u4eec\u5728call()\u7684\u5b9e\u73b0\u4e0a\u7b80\u5355\u6539\u4e00\u4e0b\u5165\u53c2\u5f62\u5f0f\u5373\u53ef<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">Function.prototype.myApply = function(thisArg, args) {\n    const fn = Symbol('fn')        \/\/ \u58f0\u660e\u4e00\u4e2a\u72ec\u6709\u7684Symbol\u5c5e\u6027, \u9632\u6b62fn\u8986\u76d6\u5df2\u6709\u5c5e\u6027\n    thisArg = thisArg || window    \/\/ \u82e5\u6ca1\u6709\u4f20\u5165this, \u9ed8\u8ba4\u7ed1\u5b9awindow\u5bf9\u8c61\n    thisArg[fn] = this              \/\/ this\u6307\u5411\u8c03\u7528call\u7684\u5bf9\u8c61,\u5373\u6211\u4eec\u8981\u6539\u53d8this\u6307\u5411\u7684\u51fd\u6570\n    const result = thisArg[fn](...args)  \/\/ \u6267\u884c\u5f53\u524d\u51fd\u6570\n    delete thisArg[fn]              \/\/ \u5220\u9664\u6211\u4eec\u58f0\u660e\u7684fn\u5c5e\u6027\n    return result                  \/\/ \u8fd4\u56de\u51fd\u6570\u6267\u884c\u7ed3\u679c\n}\n\n\/\/\u6d4b\u8bd5\nfoo.myApply(obj, [])     \/\/ \u8f93\u51fa'\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb'\n\n<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">5. \u624b\u5199bind()<\/h3>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">bind()<\/code> \u65b9\u6cd5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u51fd\u6570\uff0c\u5728 bind() \u88ab\u8c03\u7528\u65f6\uff0c\u8fd9\u4e2a\u65b0\u51fd\u6570\u7684 this \u88ab\u6307\u5b9a\u4e3a bind() \u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\uff0c\u800c\u5176\u4f59\u53c2\u6570\u5c06\u4f5c\u4e3a\u65b0\u51fd\u6570\u7684\u53c2\u6570\uff0c\u4f9b\u8c03\u7528\u65f6\u4f7f\u7528\u3002<br \/>\n\u8bed\u6cd5: function.bind(thisArg, arg1, arg2, &#8230;)\n<\/p><\/blockquote>\n<p style=\"margin: 1em 0px;\">\u4ece\u7528\u6cd5\u4e0a\u770b\uff0c\u4f3c\u4e4e\u7ed9call\/apply\u5305\u4e00\u5c42function\u5c31\u5b9e\u73b0\u4e86bind()\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">Function.prototype.myBind = function(thisArg, ...args) {\n    return () =&gt; {\n        this.apply(thisArg, args)\n    }\n}\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4f46\u6211\u4eec\u5ffd\u7565\u4e86\u4e09\u70b9\uff1a<\/p>\n<ol style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem;\">\n<li>\n<section>bind()\u9664\u4e86this\u8fd8\u63a5\u6536\u5176\u4ed6\u53c2\u6570\uff0cbind()\u8fd4\u56de\u7684\u51fd\u6570\u4e5f\u63a5\u6536\u53c2\u6570\uff0c\u8fd9\u4e24\u90e8\u5206\u7684\u53c2\u6570\u90fd\u8981\u4f20\u7ed9\u8fd4\u56de\u7684\u51fd\u6570<\/section>\n<\/li>\n<li>\n<section>new\u7684\u4f18\u5148\u7ea7\uff1a\u5982\u679cbind\u7ed1\u5b9a\u540e\u7684\u51fd\u6570\u88abnew\u4e86\uff0c\u90a3\u4e48\u6b64\u65f6this\u6307\u5411\u5c31\u53d1\u751f\u6539\u53d8\u3002\u6b64\u65f6\u7684this\u5c31\u662f\u5f53\u524d\u51fd\u6570\u7684\u5b9e\u4f8b<\/section>\n<\/li>\n<li>\n<section>\u6ca1\u6709\u4fdd\u7559\u539f\u51fd\u6570\u5728\u539f\u578b\u94fe\u4e0a\u7684\u5c5e\u6027\u548c\u65b9\u6cd5<\/section>\n<\/li>\n<\/ol>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">Function.prototype.myBind = function (thisArg, ...args) {\n    var self = this\n    \/\/ new\u4f18\u5148\u7ea7\n    var fbound = function () {\n        self.apply(this instanceof self ? this : thisArg, args.concat(Array.prototype.slice.call(arguments)))\n    }\n    \/\/ \u7ee7\u627f\u539f\u578b\u4e0a\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\n    fbound.prototype = Object.create(self.prototype);\n\n    return fbound;\n}\n\n\/\/\u6d4b\u8bd5\nconst obj = { name: '\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb' }\nfunction foo() {\n    console.log(this.name)\n    console.log(arguments)\n}\n\nfoo.myBind(obj, 'a', 'b', 'c')()    \/\/\u8f93\u51fa\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb ['a', 'b', 'c']\n\n<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">6. \u624b\u5199\u4e00\u4e2a\u9632\u6296\u51fd\u6570<\/h3>\n<p style=\"margin: 1em 0px;\">\u9632\u6296\u548c\u8282\u6d41\u7684\u6982\u5ff5\u90fd\u6bd4\u8f83\u7b80\u5355\uff0c\u6240\u4ee5\u6211\u4eec\u5c31\u4e0d\u5728\u201c\u9632\u6296\u8282\u6d41\u662f\u4ec0\u4e48\u201d\u8fd9\u4e2a\u95ee\u9898\u4e0a\u6d6a\u8d39\u8fc7\u591a\u7bc7\u5e45\u4e86\uff0c\u7b80\u5355\u70b9\u4e00\u4e0b\uff1a<\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u9632\u6296\uff0c\u5373<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u77ed\u65f6\u95f4\u5185\u5927\u91cf\u89e6\u53d1\u540c\u4e00\u4e8b\u4ef6\uff0c\u53ea\u4f1a\u6267\u884c\u4e00\u6b21\u51fd\u6570<\/code>\uff0c\u5b9e\u73b0\u539f\u7406\u4e3a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u8bbe\u7f6e\u4e00\u4e2a\u5b9a\u65f6\u5668\uff0c\u7ea6\u5b9a\u5728xx\u6beb\u79d2\u540e\u518d\u89e6\u53d1\u4e8b\u4ef6\u5904\u7406\uff0c\u6bcf\u6b21\u89e6\u53d1\u4e8b\u4ef6\u90fd\u4f1a\u91cd\u65b0\u8bbe\u7f6e\u8ba1\u65f6\u5668\uff0c\u76f4\u5230xx\u6beb\u79d2\u5185\u65e0\u7b2c\u4e8c\u6b21\u64cd\u4f5c<\/code>\uff0c\u9632\u6296\u5e38\u7528\u4e8e\u641c\u7d22\u6846\/\u6eda\u52a8\u6761\u7684\u76d1\u542c\u4e8b\u4ef6\u5904\u7406\uff0c\u5982\u679c\u4e0d\u505a\u9632\u6296\uff0c\u6bcf\u8f93\u5165\u4e00\u4e2a\u5b57\/\u6eda\u52a8\u5c4f\u5e55\uff0c\u90fd\u4f1a\u89e6\u53d1\u4e8b\u4ef6\u5904\u7406\uff0c\u9020\u6210\u6027\u80fd\u6d6a\u8d39\u3002\n<\/p><\/blockquote>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">function debounce(func, wait) {\n    let timeout = null\n    return function() {\n        let context = this\n        let args = arguments\n        if (timeout) clearTimeout(timeout)\n        timeout = setTimeout(() =&gt; {\n            func.apply(context, args)\n        }, wait)\n    }\n}\n\n<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">7. \u624b\u5199\u4e00\u4e2a\u8282\u6d41\u51fd\u6570<\/h3>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u9632\u6296\u662f<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u5ef6\u8fdf\u6267\u884c<\/code>\uff0c\u800c\u8282\u6d41\u662f<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u95f4\u9694\u6267\u884c<\/code>\uff0c\u51fd\u6570\u8282\u6d41\u5373<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u6bcf\u9694\u4e00\u6bb5\u65f6\u95f4\u5c31\u6267\u884c\u4e00\u6b21<\/code>\uff0c\u5b9e\u73b0\u539f\u7406\u4e3a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u8bbe\u7f6e\u4e00\u4e2a\u5b9a\u65f6\u5668\uff0c\u7ea6\u5b9axx\u6beb\u79d2\u540e\u6267\u884c\u4e8b\u4ef6\uff0c\u5982\u679c\u65f6\u95f4\u5230\u4e86\uff0c\u90a3\u4e48\u6267\u884c\u51fd\u6570\u5e76\u91cd\u7f6e\u5b9a\u65f6\u5668<\/code>\uff0c\u548c\u9632\u6296\u7684\u533a\u522b\u5728\u4e8e\uff0c\u9632\u6296\u6bcf\u6b21\u89e6\u53d1\u4e8b\u4ef6\u90fd\u91cd\u7f6e\u5b9a\u65f6\u5668\uff0c\u800c\u8282\u6d41\u5728\u5b9a\u65f6\u5668\u5230\u65f6\u95f4\u540e\u518d\u6e05\u7a7a\u5b9a\u65f6\u5668\n<\/p><\/blockquote>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">function throttle(func, wait) {\n    let timeout = null\n    return function() {\n        let context = this\n        let args = arguments\n        if (!timeout) {\n            timeout = setTimeout(() =&gt; {\n                timeout = null\n                func.apply(context, args)\n            }, wait)\n        }\n\n    }\n}\n\n<\/code><\/pre>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u5b9e\u73b0\u65b9\u5f0f2\uff1a\u4f7f\u7528\u4e24\u4e2a\u65f6\u95f4\u6233<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">prev\u65e7\u65f6\u95f4\u6233<\/code>\u548c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">now\u65b0\u65f6\u95f4\u6233<\/code>\uff0c\u6bcf\u6b21\u89e6\u53d1\u4e8b\u4ef6\u90fd\u5224\u65ad\u4e8c\u8005\u7684\u65f6\u95f4\u5dee\uff0c\u5982\u679c\u5230\u8fbe\u89c4\u5b9a\u65f6\u95f4\uff0c\u6267\u884c\u51fd\u6570\u5e76\u91cd\u7f6e\u65e7\u65f6\u95f4\u6233\n<\/p><\/blockquote>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">function throttle(func, wait) {\n    var prev = 0;\n    return function() {\n        let now = Date.now();\n        let context = this;\n        let args = arguments;\n        if (now - prev &gt; wait) {\n            func.apply(context, args);\n            prev = now;\n        }\n    }\n}\n\n<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">8. \u6570\u7ec4\u6241\u5e73\u5316<\/h3>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u5bf9\u4e8e<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">[1, [1,2], [1,2,3]]<\/code>\u8fd9\u6837\u591a\u5c42\u5d4c\u5957\u7684\u6570\u7ec4\uff0c\u6211\u4eec\u5982\u4f55\u5c06\u5176\u6241\u5e73\u5316\u4e3a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">[1, 1, 2, 1, 2, 3]<\/code>\u8fd9\u6837\u7684\u4e00\u7ef4\u6570\u7ec4\u5462\uff1a\n<\/p><\/blockquote>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">1.ES6\u7684flat()<\/strong><\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">const arr = [1, [1,2], [1,2,3]]\narr.flat(Infinity)  \/\/ [1, 1, 2, 1, 2, 3]\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">2.\u5e8f\u5217\u5316\u540e\u6b63\u5219<\/strong><\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">const arr = [1, [1,2], [1,2,3]]\nconst str = `[${JSON.stringify(arr).replace(\/(\\[|\\])\/g, '')}]`\nJSON.parse(str)   \/\/ [1, 1, 2, 1, 2, 3]\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">3.\u9012\u5f52<\/strong> \u5bf9\u4e8e\u6811\u72b6\u7ed3\u6784\u7684\u6570\u636e\uff0c\u6700\u76f4\u63a5\u7684\u5904\u7406\u65b9\u5f0f\u5c31\u662f\u9012\u5f52<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">const arr = [1, [1,2], [1,2,3]]\nfunction flat(arr) {\n  let result = []\n  for (const item of arr) {\n    item instanceof Array ? result = result.concat(flat(item)) : result.push(item)\n  }\n  return result\n}\n\nflat(arr) \/\/ [1, 1, 2, 1, 2, 3]\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">4.reduce()\u9012\u5f52<\/strong><\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">const arr = [1, [1,2], [1,2,3]]\nfunction flat(arr) {\n  return arr.reduce((prev, cur) =&gt; {\n    return prev.concat(cur instanceof Array ? flat(cur) : cur)\n  }, [])\n}\n\nflat(arr)  \/\/ [1, 1, 2, 1, 2, 3]\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">5.\u8fed\u4ee3+\u5c55\u5f00\u8fd0\u7b97\u7b26<\/strong><\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/ \u6bcf\u6b21while\u90fd\u4f1a\u5408\u5e76\u4e00\u5c42\u7684\u5143\u7d20\uff0c\u8fd9\u91cc\u7b2c\u4e00\u6b21\u5408\u5e76\u7ed3\u679c\u4e3a[1, 1, 2, 1, 2, 3, [4,4,4]]\n\/\/ \u7136\u540earr.some\u5224\u5b9a\u6570\u7ec4\u4e2d\u662f\u5426\u5b58\u5728\u6570\u7ec4\uff0c\u56e0\u4e3a\u5b58\u5728[4,4,4]\uff0c\u7ee7\u7eed\u8fdb\u5165\u7b2c\u4e8c\u6b21\u5faa\u73af\u8fdb\u884c\u5408\u5e76\nlet arr = [1, [1,2], [1,2,3,[4,4,4]]]\nwhile (arr.some(Array.isArray)) {\n  arr = [].concat(...arr);\n}\n\nconsole.log(arr)  \/\/ [1, 1, 2, 1, 2, 3, 4, 4, 4]\n\n<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">9. \u624b\u5199\u4e00\u4e2aPromise<\/h3>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u5b9e\u73b0\u4e00\u4e2a\u7b26\u5408\u89c4\u8303\u7684Promise\u7bc7\u5e45\u6bd4\u8f83\u957f\uff0c\u5efa\u8bae\u9605\u8bfb\u7b14\u8005\u4e0a\u4e00\u7bc7\u6587\u7ae0\uff1a<a href=\"https:\/\/juejin.im\/post\/5e3b9ae26fb9a07ca714a5cc\">\u5f02\u6b65\u7f16\u7a0b\u4e8c\u4e09\u4e8b | Promise\/async\/Generator\u5b9e\u73b0\u539f\u7406\u89e3\u6790 | 9k\u5b57<\/a>\n<\/p><\/blockquote>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">JS\u9762\u5411\u5bf9\u8c61<\/h2>\n<p style=\"margin: 1em 0px;\">\u5728JS\u4e2d\u4e00\u5207\u7686\u5bf9\u8c61\uff0c\u4f46JS\u5e76\u4e0d\u662f\u4e00\u79cd\u771f\u6b63\u7684\u9762\u5411\u5bf9\u8c61(OOP)\u7684\u8bed\u8a00\uff0c\u56e0\u4e3a\u5b83\u7f3a\u5c11<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u7c7b(class)<\/code>\u7684\u6982\u5ff5\u3002\u867d\u7136ES6\u5f15\u5165\u4e86<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">class<\/code>\u548c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">extends<\/code>\uff0c\u4f7f\u6211\u4eec\u80fd\u591f\u8f7b\u6613\u5730\u5b9e\u73b0\u7c7b\u548c\u7ee7\u627f\u3002\u4f46JS\u5e76\u4e0d\u5b58\u5728\u771f\u5b9e\u7684\u7c7b\uff0cJS\u7684\u7c7b\u662f\u901a\u8fc7\u51fd\u6570\u4ee5\u53ca\u539f\u578b\u94fe\u673a\u5236\u6a21\u62df\u7684\uff0c\u672c\u5c0f\u8282\u7684\u5c31\u6765\u63a2\u7a76\u5982\u4f55\u5728ES5\u73af\u5883\u4e0b\u5229\u7528\u51fd\u6570\u548c\u539f\u578b\u94fe\u5b9e\u73b0JS\u9762\u5411\u5bf9\u8c61\u7684\u7279\u6027<\/p>\n<p style=\"margin: 1em 0px;\">\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u56de\u987e\u4e00\u4e0b\u539f\u578b\u94fe\u7684\u77e5\u8bc6\uff0c\u540e\u7eed<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">new<\/code>\u548c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u7ee7\u627f<\/code>\u7b49\u5b9e\u73b0\u90fd\u662f\u57fa\u4e8e\u539f\u578b\u94fe\u673a\u5236\u3002\u5f88\u591a\u4ecb\u7ecd\u539f\u578b\u94fe\u7684\u8d44\u6599\u90fd\u80fd\u5199\u4e0a\u6d0b\u6d0b\u6d12\u6d12\u51e0\u5343\u5b57\uff0c\u4f46\u6211\u89c9\u5f97\u8bfb\u8005\u4eec\u4e0d\u9700\u8981\u628a\u539f\u578b\u94fe\u60f3\u592a\u590d\u6742\uff0c\u5bb9\u6613\u628a\u81ea\u5df1\u7ed5\u8fdb\u53bb\uff0c\u5176\u5b9e\u5728\u6211\u770b\u6765\uff0c\u539f\u578b\u94fe\u7684\u6838\u5fc3\u53ea\u9700\u8981\u8bb0\u4f4f\u4e09\u70b9\uff1a<\/p>\n<ol style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem;\">\n<li>\n<section>\u6bcf\u4e2a\u5bf9\u8c61\u90fd\u6709<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">__proto__\u5c5e\u6027<\/code>\uff0c\u8be5\u5c5e\u6027\u6307\u5411\u5176\u539f\u578b\u5bf9\u8c61\uff0c\u5728\u8c03\u7528\u5b9e\u4f8b\u7684\u65b9\u6cd5\u548c\u5c5e\u6027\u65f6\uff0c\u5982\u679c\u5728\u5b9e\u4f8b\u5bf9\u8c61\u4e0a\u627e\u4e0d\u5230\uff0c\u5c31\u4f1a\u5f80\u539f\u578b\u5bf9\u8c61\u4e0a\u627e<\/section>\n<\/li>\n<li>\n<section>\u6784\u9020\u51fd\u6570\u7684<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">prototype\u5c5e\u6027<\/code>\u4e5f\u6307\u5411\u5b9e\u4f8b\u7684\u539f\u578b\u5bf9\u8c61<\/section>\n<\/li>\n<li>\n<section>\u539f\u578b\u5bf9\u8c61\u7684<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">constructor\u5c5e\u6027<\/code>\u6307\u5411\u6784\u9020\u51fd\u6570<\/section>\n<\/li>\n<\/ol>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">1. \u6a21\u62df\u5b9e\u73b0new<\/h3>\n<p style=\"margin: 1em 0px;\">\u9996\u5148\u6211\u4eec\u8981\u77e5\u9053<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">new<\/code>\u505a\u4e86\u4ec0\u4e48<\/p>\n<ol style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem;\">\n<li>\n<section><strong style=\"color: #4870ac;\">\u521b\u5efa\u4e00\u4e2a\u65b0\u5bf9\u8c61\uff0c\u5e76\u7ee7\u627f\u5176\u6784\u9020\u51fd\u6570\u7684<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">prototype<\/code><\/strong>\uff0c\u8fd9\u4e00\u6b65\u662f\u4e3a\u4e86\u7ee7\u627f\u6784\u9020\u51fd\u6570\u539f\u578b\u4e0a\u7684\u5c5e\u6027\u548c\u65b9\u6cd5<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u6267\u884c\u6784\u9020\u51fd\u6570\uff0c\u65b9\u6cd5\u5185\u7684<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">this<\/code>\u88ab\u6307\u5b9a\u4e3a\u8be5\u65b0\u5b9e\u4f8b<\/strong>\uff0c\u8fd9\u4e00\u6b65\u662f\u4e3a\u4e86\u6267\u884c\u6784\u9020\u51fd\u6570\u5185\u7684\u8d4b\u503c\u64cd\u4f5c<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u8fd4\u56de\u65b0\u5b9e\u4f8b<\/strong>\uff08\u89c4\u8303\u89c4\u5b9a\uff0c\u5982\u679c\u6784\u9020\u65b9\u6cd5\u8fd4\u56de\u4e86\u4e00\u4e2a\u5bf9\u8c61\uff0c\u90a3\u4e48\u8fd4\u56de\u8be5\u5bf9\u8c61\uff0c\u5426\u5219\u8fd4\u56de\u7b2c\u4e00\u6b65\u521b\u5efa\u7684\u65b0\u5bf9\u8c61\uff09<\/section>\n<\/li>\n<\/ol>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/ new\u662f\u5173\u952e\u5b57,\u8fd9\u91cc\u6211\u4eec\u7528\u51fd\u6570\u6765\u6a21\u62df,new Foo(args) &lt;=&gt; myNew(Foo, args)\nfunction myNew(foo, ...args) {\n  \/\/ \u521b\u5efa\u65b0\u5bf9\u8c61,\u5e76\u7ee7\u627f\u6784\u9020\u65b9\u6cd5\u7684prototype\u5c5e\u6027, \u8fd9\u4e00\u6b65\u662f\u4e3a\u4e86\u628aobj\u6302\u539f\u578b\u94fe\u4e0a, \u76f8\u5f53\u4e8eobj.__proto__ = Foo.prototype\n  let obj = Object.create(foo.prototype)  \n  \n  \/\/ \u6267\u884c\u6784\u9020\u65b9\u6cd5, \u5e76\u4e3a\u5176\u7ed1\u5b9a\u65b0this, \u8fd9\u4e00\u6b65\u662f\u4e3a\u4e86\u8ba9\u6784\u9020\u65b9\u6cd5\u80fd\u8fdb\u884cthis.name = name\u4e4b\u7c7b\u7684\u64cd\u4f5c, args\u662f\u6784\u9020\u65b9\u6cd5\u7684\u5165\u53c2, \u56e0\u4e3a\u8fd9\u91cc\u7528myNew\u6a21\u62df, \u6240\u4ee5\u5165\u53c2\u4ecemyNew\u4f20\u5165\n  let result = foo.apply(obj, args)\n\n  \/\/ \u5982\u679c\u6784\u9020\u65b9\u6cd5\u5df2\u7ecfreturn\u4e86\u4e00\u4e2a\u5bf9\u8c61, \u90a3\u4e48\u5c31\u8fd4\u56de\u8be5\u5bf9\u8c61, \u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6784\u9020\u65b9\u6cd5\u4e0d\u4f1a\u8fd4\u56de\u65b0\u5b9e\u4f8b\uff0c\u4f46\u4f7f\u7528\u8005\u53ef\u4ee5\u9009\u62e9\u8fd4\u56de\u65b0\u5b9e\u4f8b\u6765\u8986\u76d6new\u521b\u5efa\u7684\u5bf9\u8c61 \u5426\u5219\u8fd4\u56demyNew\u521b\u5efa\u7684\u65b0\u5bf9\u8c61\n  return typeof result === 'object' &amp;&amp; result !== null ? result : obj\n}\n\nfunction Foo(name) {\n  this.name = name\n}\nconst newObj = myNew(Foo, 'zhangsan')\nconsole.log(newObj)                 \/\/ Foo {name: \"zhangsan\"}\nconsole.log(newObj instanceof Foo)  \/\/ true\n\n<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">2. ES5\u5982\u4f55\u5b9e\u73b0\u7ee7\u627f<\/h3>\n<p style=\"margin: 1em 0px;\">\u8bf4\u5230\u7ee7\u627f\uff0c\u6700\u5bb9\u6613\u60f3\u5230\u7684\u662fES6\u7684<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">extends<\/code>\uff0c\u5f53\u7136\u5982\u679c\u53ea\u56de\u7b54\u8fd9\u4e2a\u80af\u5b9a\u4e0d\u5408\u683c\uff0c\u6211\u4eec\u8981\u4ece\u51fd\u6570\u548c\u539f\u578b\u94fe\u7684\u89d2\u5ea6\u4e0a\u5b9e\u73b0\u7ee7\u627f\uff0c\u4e0b\u9762\u6211\u4eec\u4e00\u6b65\u6b65\u5730\u3001\u9012\u8fdb\u5730\u5b9e\u73b0\u4e00\u4e2a\u5408\u683c\u7684\u7ee7\u627f<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u4e00. \u539f\u578b\u94fe\u7ee7\u627f<\/h3>\n<p style=\"margin: 1em 0px;\">\u539f\u578b\u94fe\u7ee7\u627f\u7684\u539f\u7406\u5f88\u7b80\u5355\uff0c\u76f4\u63a5\u8ba9\u5b50\u7c7b\u7684\u539f\u578b\u5bf9\u8c61\u6307\u5411\u7236\u7c7b\u5b9e\u4f8b\uff0c\u5f53\u5b50\u7c7b\u5b9e\u4f8b\u627e\u4e0d\u5230\u5bf9\u5e94\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u65f6\uff0c\u5c31\u4f1a\u5f80\u5b83\u7684\u539f\u578b\u5bf9\u8c61\uff0c\u4e5f\u5c31\u662f\u7236\u7c7b\u5b9e\u4f8b\u4e0a\u627e\uff0c\u4ece\u800c\u5b9e\u73b0\u5bf9\u7236\u7c7b\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u7684\u7ee7\u627f<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/ \u7236\u7c7b\nfunction Parent() {\n    this.name = '\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb'\n}\n\/\/ \u7236\u7c7b\u7684\u539f\u578b\u65b9\u6cd5\nParent.prototype.getName = function() {\n    return this.name\n}\n\/\/ \u5b50\u7c7b\nfunction Child() {}\n\n\/\/ \u8ba9\u5b50\u7c7b\u7684\u539f\u578b\u5bf9\u8c61\u6307\u5411\u7236\u7c7b\u5b9e\u4f8b, \u8fd9\u6837\u4e00\u6765\u5728Child\u5b9e\u4f8b\u4e2d\u627e\u4e0d\u5230\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u5c31\u4f1a\u5230\u539f\u578b\u5bf9\u8c61(\u7236\u7c7b\u5b9e\u4f8b)\u4e0a\u5bfb\u627e\nChild.prototype = new Parent()\nChild.prototype.constructor = Child \/\/ \u6839\u636e\u539f\u578b\u94fe\u7684\u89c4\u5219,\u987a\u4fbf\u7ed1\u5b9a\u4e00\u4e0bconstructor, \u8fd9\u4e00\u6b65\u4e0d\u5f71\u54cd\u7ee7\u627f, \u53ea\u662f\u5728\u7528\u5230constructor\u65f6\u4f1a\u9700\u8981\n\n\/\/ \u7136\u540eChild\u5b9e\u4f8b\u5c31\u80fd\u8bbf\u95ee\u5230\u7236\u7c7b\u53ca\u5176\u539f\u578b\u4e0a\u7684name\u5c5e\u6027\u548cgetName()\u65b9\u6cd5\nconst child = new Child()\nchild.name          \/\/ '\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb'\nchild.getName()     \/\/ '\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb'\n\n<\/code><\/pre>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u539f\u578b\u7ee7\u627f\u7684\u7f3a\u70b9:\n<\/p><\/blockquote>\n<ol style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem;\">\n<li>\n<section>\u7531\u4e8e\u6240\u6709Child\u5b9e\u4f8b\u539f\u578b\u90fd\u6307\u5411\u540c\u4e00\u4e2aParent\u5b9e\u4f8b, \u56e0\u6b64\u5bf9\u67d0\u4e2aChild\u5b9e\u4f8b\u7684\u7236\u7c7b\u5f15\u7528\u7c7b\u578b\u53d8\u91cf\u4fee\u6539\u4f1a\u5f71\u54cd\u6240\u6709\u7684Child\u5b9e\u4f8b<\/section>\n<\/li>\n<li>\n<section>\u5728\u521b\u5efa\u5b50\u7c7b\u5b9e\u4f8b\u65f6\u65e0\u6cd5\u5411\u7236\u7c7b\u6784\u9020\u4f20\u53c2, \u5373\u6ca1\u6709\u5b9e\u73b0<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">super()<\/code>\u7684\u529f\u80fd<\/section>\n<\/li>\n<\/ol>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/ \u793a\u4f8b:\nfunction Parent() {\n    this.name = ['\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb'] \n}\nParent.prototype.getName = function() {\n    return this.name\n}\nfunction Child() {}\n\nChild.prototype = new Parent()\nChild.prototype.constructor = Child \n\n\/\/ \u6d4b\u8bd5\nconst child1 = new Child()\nconst child2 = new Child()\nchild1.name[0] = 'foo'\nconsole.log(child1.name)          \/\/ ['foo']\nconsole.log(child2.name)          \/\/ ['foo'] (\u9884\u671f\u662f['\u5199\u4ee3\u7801\u50cf\u8521\u5f90\u62bb'], \u5bf9child1.name\u7684\u4fee\u6539\u5f15\u8d77\u4e86\u6240\u6709child\u5b9e\u4f8b\u7684\u53d8\u5316)\n\n<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u4e8c. \u6784\u9020\u51fd\u6570\u7ee7\u627f<\/h3>\n<p style=\"margin: 1em 0px;\">\u6784\u9020\u51fd\u6570\u7ee7\u627f\uff0c\u5373\u5728\u5b50\u7c7b\u7684\u6784\u9020\u51fd\u6570\u4e2d\u6267\u884c\u7236\u7c7b\u7684\u6784\u9020\u51fd\u6570\uff0c\u5e76\u4e3a\u5176\u7ed1\u5b9a\u5b50\u7c7b\u7684<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">this<\/code>\uff0c\u8ba9\u7236\u7c7b\u7684\u6784\u9020\u51fd\u6570\u628a\u6210\u5458\u5c5e\u6027\u548c\u65b9\u6cd5\u90fd\u6302\u5230<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u5b50\u7c7b\u7684this<\/code>\u4e0a\u53bb\uff0c\u8fd9\u6837\u65e2\u80fd\u907f\u514d\u5b9e\u4f8b\u4e4b\u95f4\u5171\u4eab\u4e00\u4e2a\u539f\u578b\u5b9e\u4f8b\uff0c\u53c8\u80fd\u5411\u7236\u7c7b\u6784\u9020\u65b9\u6cd5\u4f20\u53c2<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">function Parent(name) {\n    this.name = [name]\n}\nParent.prototype.getName = function() {\n    return this.name\n}\nfunction Child() {\n    Parent.call(this, 'zhangsan')   \/\/ \u6267\u884c\u7236\u7c7b\u6784\u9020\u65b9\u6cd5\u5e76\u7ed1\u5b9a\u5b50\u7c7b\u7684this, \u4f7f\u5f97\u7236\u7c7b\u4e2d\u7684\u5c5e\u6027\u80fd\u591f\u8d4b\u5230\u5b50\u7c7b\u7684this\u4e0a\n}\n\n\/\/\u6d4b\u8bd5\nconst child1 = new Child()\nconst child2 = new Child()\nchild1.name[0] = 'foo'\nconsole.log(child1.name)          \/\/ ['foo']\nconsole.log(child2.name)          \/\/ ['zhangsan']\nchild2.getName()                  \/\/ \u62a5\u9519,\u627e\u4e0d\u5230getName(), \u6784\u9020\u51fd\u6570\u7ee7\u627f\u7684\u65b9\u5f0f\u7ee7\u627f\u4e0d\u5230\u7236\u7c7b\u539f\u578b\u4e0a\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\n\n<\/code><\/pre>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u6784\u9020\u51fd\u6570\u7ee7\u627f\u7684\u7f3a\u70b9:\n<\/p><\/blockquote>\n<ol style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem;\">\n<li>\n<section>\u7ee7\u627f\u4e0d\u5230\u7236\u7c7b\u539f\u578b\u4e0a\u7684\u5c5e\u6027\u548c\u65b9\u6cd5<\/section>\n<\/li>\n<\/ol>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u4e09. \u7ec4\u5408\u5f0f\u7ee7\u627f<\/h3>\n<p style=\"margin: 1em 0px;\">\u65e2\u7136\u539f\u578b\u94fe\u7ee7\u627f\u548c\u6784\u9020\u51fd\u6570\u7ee7\u627f\u5404\u6709\u4e92\u8865\u7684\u4f18\u7f3a\u70b9, \u90a3\u4e48\u6211\u4eec\u4e3a\u4ec0\u4e48\u4e0d\u7ec4\u5408\u8d77\u6765\u4f7f\u7528\u5462, \u6240\u4ee5\u5c31\u6709\u4e86\u7efc\u5408\u4e8c\u8005\u7684\u7ec4\u5408\u5f0f\u7ee7\u627f<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">function Parent(name) {\n    this.name = [name]\n}\nParent.prototype.getName = function() {\n    return this.name\n}\nfunction Child() {\n    \/\/ \u6784\u9020\u51fd\u6570\u7ee7\u627f\n    Parent.call(this, 'zhangsan') \n}\n\/\/\u539f\u578b\u94fe\u7ee7\u627f\nChild.prototype = new Parent()\nChild.prototype.constructor = Child\n\n\/\/\u6d4b\u8bd5\nconst child1 = new Child()\nconst child2 = new Child()\nchild1.name[0] = 'foo'\nconsole.log(child1.name)          \/\/ ['foo']\nconsole.log(child2.name)          \/\/ ['zhangsan']\nchild2.getName()                  \/\/ ['zhangsan']\n\n<\/code><\/pre>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u7ec4\u5408\u5f0f\u7ee7\u627f\u7684\u7f3a\u70b9:\n<\/p><\/blockquote>\n<ol style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem;\">\n<li>\n<section>\u6bcf\u6b21\u521b\u5efa\u5b50\u7c7b\u5b9e\u4f8b\u90fd\u6267\u884c\u4e86\u4e24\u6b21\u6784\u9020\u51fd\u6570(<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">Parent.call()<\/code>\u548c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">new Parent()<\/code>)\uff0c\u867d\u7136\u8fd9\u5e76\u4e0d\u5f71\u54cd\u5bf9\u7236\u7c7b\u7684\u7ee7\u627f\uff0c\u4f46\u5b50\u7c7b\u521b\u5efa\u5b9e\u4f8b\u65f6\uff0c\u539f\u578b\u4e2d\u4f1a\u5b58\u5728\u4e24\u4efd\u76f8\u540c\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u8fd9\u5e76\u4e0d\u4f18\u96c5<\/section>\n<\/li>\n<\/ol>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u56db. \u5bc4\u751f\u5f0f\u7ec4\u5408\u7ee7\u627f<\/h3>\n<p style=\"margin: 1em 0px;\">\u4e3a\u4e86\u89e3\u51b3\u6784\u9020\u51fd\u6570\u88ab\u6267\u884c\u4e24\u6b21\u7684\u95ee\u9898, \u6211\u4eec\u5c06<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u6307\u5411\u7236\u7c7b\u5b9e\u4f8b<\/code>\u6539\u4e3a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u6307\u5411\u7236\u7c7b\u539f\u578b<\/code>, \u51cf\u53bb\u4e00\u6b21\u6784\u9020\u51fd\u6570\u7684\u6267\u884c<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">function Parent(name) {\n    this.name = [name]\n}\nParent.prototype.getName = function() {\n    return this.name\n}\nfunction Child() {\n    \/\/ \u6784\u9020\u51fd\u6570\u7ee7\u627f\n    Parent.call(this, 'zhangsan') \n}\n\/\/\u539f\u578b\u94fe\u7ee7\u627f\n\/\/ Child.prototype = new Parent()\nChild.prototype = Parent.prototype  \/\/\u5c06`\u6307\u5411\u7236\u7c7b\u5b9e\u4f8b`\u6539\u4e3a`\u6307\u5411\u7236\u7c7b\u539f\u578b`\nChild.prototype.constructor = Child\n\n\/\/\u6d4b\u8bd5\nconst child1 = new Child()\nconst child2 = new Child()\nchild1.name[0] = 'foo'\nconsole.log(child1.name)          \/\/ ['foo']\nconsole.log(child2.name)          \/\/ ['zhangsan']\nchild2.getName()                  \/\/ ['zhangsan']\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4f46\u8fd9\u79cd\u65b9\u5f0f\u5b58\u5728\u4e00\u4e2a\u95ee\u9898\uff0c\u7531\u4e8e\u5b50\u7c7b\u539f\u578b\u548c\u7236\u7c7b\u539f\u578b\u6307\u5411\u540c\u4e00\u4e2a\u5bf9\u8c61\uff0c\u6211\u4eec\u5bf9\u5b50\u7c7b\u539f\u578b\u7684\u64cd\u4f5c\u4f1a\u5f71\u54cd\u5230\u7236\u7c7b\u539f\u578b\uff0c\u4f8b\u5982\u7ed9<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">Child.prototype<\/code>\u589e\u52a0\u4e00\u4e2agetName()\u65b9\u6cd5\uff0c\u90a3\u4e48\u4f1a\u5bfc\u81f4<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">Parent.prototype<\/code>\u4e5f\u589e\u52a0\u6216\u88ab\u8986\u76d6\u4e00\u4e2agetName()\u65b9\u6cd5\uff0c\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u7ed9<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">Parent.prototype<\/code>\u505a\u4e00\u4e2a\u6d45\u62f7\u8d1d<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">function Parent(name) {\n    this.name = [name]\n}\nParent.prototype.getName = function() {\n    return this.name\n}\nfunction Child() {\n    \/\/ \u6784\u9020\u51fd\u6570\u7ee7\u627f\n    Parent.call(this, 'zhangsan') \n}\n\/\/\u539f\u578b\u94fe\u7ee7\u627f\n\/\/ Child.prototype = new Parent()\nChild.prototype = Object.create(Parent.prototype)  \/\/\u5c06`\u6307\u5411\u7236\u7c7b\u5b9e\u4f8b`\u6539\u4e3a`\u6307\u5411\u7236\u7c7b\u539f\u578b`\nChild.prototype.constructor = Child\n\n\/\/\u6d4b\u8bd5\nconst child = new Child()\nconst parent = new Parent()\nchild.getName()                  \/\/ ['zhangsan']\nparent.getName()                 \/\/ \u62a5\u9519, \u627e\u4e0d\u5230getName()\n\n<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u5230\u8fd9\u91cc\u6211\u4eec\u5c31\u5b8c\u6210\u4e86ES5\u73af\u5883\u4e0b\u7684\u7ee7\u627f\u7684\u5b9e\u73b0\uff0c\u8fd9\u79cd\u7ee7\u627f\u65b9\u5f0f\u79f0\u4e3a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u5bc4\u751f\u7ec4\u5408\u5f0f\u7ee7\u627f<\/code>\uff0c\u662f\u76ee\u524d\u6700\u6210\u719f\u7684\u7ee7\u627f\u65b9\u5f0f\uff0cbabel\u5bf9ES6\u7ee7\u627f\u7684\u8f6c\u5316\u4e5f\u662f\u4f7f\u7528\u4e86\u5bc4\u751f\u7ec4\u5408\u5f0f\u7ee7\u627f<\/p>\n<p style=\"margin: 1em 0px;\">\u6211\u4eec\u56de\u987e\u4e00\u4e0b\u5b9e\u73b0\u8fc7\u7a0b\uff1a \u4e00\u5f00\u59cb\u6700\u5bb9\u6613\u60f3\u5230\u7684\u662f<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u539f\u578b\u94fe\u7ee7\u627f<\/code>\uff0c\u901a\u8fc7\u628a\u5b50\u7c7b\u5b9e\u4f8b\u7684\u539f\u578b\u6307\u5411\u7236\u7c7b\u5b9e\u4f8b\u6765\u7ee7\u627f\u7236\u7c7b\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u4f46\u539f\u578b\u94fe\u7ee7\u627f\u7684\u7f3a\u9677\u5728\u4e8e<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u5bf9\u5b50\u7c7b\u5b9e\u4f8b\u7ee7\u627f\u7684\u5f15\u7528\u7c7b\u578b\u7684\u4fee\u6539\u4f1a\u5f71\u54cd\u5230\u6240\u6709\u7684\u5b9e\u4f8b\u5bf9\u8c61<\/code>\u4ee5\u53ca<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u65e0\u6cd5\u5411\u7236\u7c7b\u7684\u6784\u9020\u65b9\u6cd5\u4f20\u53c2<\/code>\u3002 \u56e0\u6b64\u6211\u4eec\u5f15\u5165\u4e86<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u6784\u9020\u51fd\u6570\u7ee7\u627f<\/code>, \u901a\u8fc7\u5728\u5b50\u7c7b\u6784\u9020\u51fd\u6570\u4e2d\u8c03\u7528\u7236\u7c7b\u6784\u9020\u51fd\u6570\u5e76\u4f20\u5165\u5b50\u7c7bthis\u6765\u83b7\u53d6\u7236\u7c7b\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u4f46\u6784\u9020\u51fd\u6570\u7ee7\u627f\u4e5f\u5b58\u5728\u7f3a\u9677\uff0c\u6784\u9020\u51fd\u6570\u7ee7\u627f<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u4e0d\u80fd\u7ee7\u627f\u5230\u7236\u7c7b\u539f\u578b\u94fe\u4e0a\u7684\u5c5e\u6027\u548c\u65b9\u6cd5<\/code>\u3002 \u6240\u4ee5\u6211\u4eec\u7efc\u5408\u4e86\u4e24\u79cd\u7ee7\u627f\u7684\u4f18\u70b9\uff0c\u63d0\u51fa\u4e86<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u7ec4\u5408\u5f0f\u7ee7\u627f<\/code>\uff0c\u4f46\u7ec4\u5408\u5f0f\u7ee7\u627f\u4e5f\u5f15\u5165\u4e86\u65b0\u7684\u95ee\u9898\uff0c\u5b83<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u6bcf\u6b21\u521b\u5efa\u5b50\u7c7b\u5b9e\u4f8b\u90fd\u6267\u884c\u4e86\u4e24\u6b21\u7236\u7c7b\u6784\u9020\u65b9\u6cd5<\/code>\uff0c\u6211\u4eec\u901a\u8fc7\u5c06<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u5b50\u7c7b\u539f\u578b\u6307\u5411\u7236\u7c7b\u5b9e\u4f8b<\/code>\u6539\u4e3a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u5b50\u7c7b\u539f\u578b\u6307\u5411\u7236\u7c7b\u539f\u578b\u7684\u6d45\u62f7\u8d1d<\/code>\u6765\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0c\u4e5f\u5c31\u662f\u6700\u7ec8\u5b9e\u73b0 \u2014\u2014 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">\u5bc4\u751f\u7ec4\u5408\u5f0f\u7ee7\u627f<\/code><\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">V8\u5f15\u64ce\u673a\u5236<\/h2>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">1. V8\u5982\u4f55\u6267\u884c\u4e00\u6bb5JS\u4ee3\u7801<\/h3>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1701324268cca319.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2736\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1701324268cca319.png\" alt=\"1701324268cca319\" width=\"960\" height=\"540\" \/><\/a><\/p>\n<ol style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem;\">\n<li>\n<section><strong style=\"color: #4870ac;\">\u9884\u89e3\u6790<\/strong>\uff1a\u68c0\u67e5\u8bed\u6cd5\u9519\u8bef\u4f46\u4e0d\u751f\u6210AST<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u751f\u6210AST<\/strong>\uff1a\u7ecf\u8fc7\u8bcd\u6cd5\/\u8bed\u6cd5\u5206\u6790\uff0c\u751f\u6210\u62bd\u8c61\u8bed\u6cd5\u6811<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u751f\u6210\u5b57\u8282\u7801<\/strong>\uff1a\u57fa\u7ebf\u7f16\u8bd1\u5668(Ignition)\u5c06AST\u8f6c\u6362\u6210\u5b57\u8282\u7801<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u751f\u6210\u673a\u5668\u7801<\/strong>\uff1a\u4f18\u5316\u7f16\u8bd1\u5668(Turbofan)\u5c06\u5b57\u8282\u7801\u8f6c\u6362\u6210\u4f18\u5316\u8fc7\u7684\u673a\u5668\u7801\uff0c\u6b64\u5916\u5728\u9010\u884c\u6267\u884c\u5b57\u8282\u7801\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u4e00\u6bb5\u4ee3\u7801\u7ecf\u5e38\u88ab\u6267\u884c\uff0c\u90a3\u4e48V8\u4f1a\u5c06\u8fd9\u6bb5\u4ee3\u7801\u76f4\u63a5\u8f6c\u6362\u6210\u673a\u5668\u7801\u4fdd\u5b58\u8d77\u6765\uff0c\u4e0b\u4e00\u6b21\u6267\u884c\u5c31\u4e0d\u5fc5\u7ecf\u8fc7\u5b57\u8282\u7801\uff0c\u4f18\u5316\u4e86\u6267\u884c\u901f\u5ea6<\/section>\n<\/li>\n<\/ol>\n<p style=\"margin: 1em 0px;\">\u4e0a\u9762\u51e0\u70b9\u53ea\u662fV8\u6267\u884c\u673a\u5236\u7684\u6781\u7b80\u603b\u7ed3\uff0c\u5efa\u8bae\u9605\u8bfb\u53c2\u8003\u8d44\u6599\uff1a<\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n1.<a href=\"https:\/\/juejin.im\/post\/5dc4d823f265da4d4c202d3b\">V8 \u662f\u600e\u4e48\u8dd1\u8d77\u6765\u7684 \u2014\u2014 V8 \u7684 JavaScript \u6267\u884c\u7ba1\u9053<\/a><br \/>\n2.<a href=\"https:\/\/juejin.im\/post\/5df1ed1f6fb9a015fd69b78d\">JavaScript \u5f15\u64ce V8 \u6267\u884c\u6d41\u7a0b\u6982\u8ff0<\/a>\n<\/p><\/blockquote>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">2. \u4ecb\u7ecd\u4e00\u4e0b\u5f15\u7528\u8ba1\u6570\u548c\u6807\u8bb0\u6e05\u9664<\/h3>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><strong style=\"color: #4870ac;\">\u5f15\u7528\u8ba1\u6570<\/strong>\uff1a\u7ed9\u4e00\u4e2a\u53d8\u91cf\u8d4b\u503c\u5f15\u7528\u7c7b\u578b\uff0c\u5219\u8be5\u5bf9\u8c61\u7684\u5f15\u7528\u6b21\u6570+1\uff0c\u5982\u679c\u8fd9\u4e2a\u53d8\u91cf\u53d8\u6210\u4e86\u5176\u4ed6\u503c\uff0c\u90a3\u4e48\u8be5\u5bf9\u8c61\u7684\u5f15\u7528\u6b21\u6570-1\uff0c\u5783\u573e\u56de\u6536\u5668\u4f1a\u56de\u6536\u5f15\u7528\u6b21\u6570\u4e3a0\u7684\u5bf9\u8c61\u3002\u4f46\u662f\u5f53\u5bf9\u8c61\u5faa\u73af\u5f15\u7528\u65f6\uff0c\u4f1a\u5bfc\u81f4\u5f15\u7528\u6b21\u6570\u6c38\u8fdc\u65e0\u6cd5\u5f52\u96f6\uff0c\u9020\u6210\u5185\u5b58\u65e0\u6cd5\u91ca\u653e\u3002<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u6807\u8bb0\u6e05\u9664<\/strong>\uff1a\u5783\u573e\u6536\u96c6\u5668\u5148\u7ed9\u5185\u5b58\u4e2d\u6240\u6709\u5bf9\u8c61\u52a0\u4e0a\u6807\u8bb0\uff0c\u7136\u540e\u4ece\u6839\u8282\u70b9\u5f00\u59cb\u904d\u5386\uff0c\u53bb\u6389\u88ab\u5f15\u7528\u7684\u5bf9\u8c61\u548c\u8fd0\u884c\u73af\u5883\u4e2d\u5bf9\u8c61\u7684\u6807\u8bb0\uff0c\u5269\u4e0b\u7684\u88ab\u6807\u8bb0\u7684\u5bf9\u8c61\u5c31\u662f\u65e0\u6cd5\u8bbf\u95ee\u7684\u7b49\u5f85\u56de\u6536\u7684\u5bf9\u8c61\u3002<\/section>\n<\/li>\n<\/ul>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">3. V8\u5982\u4f55\u8fdb\u884c\u5783\u573e\u56de\u6536<\/h3>\n<p style=\"margin: 1em 0px;\">JS\u5f15\u64ce\u4e2d\u5bf9\u53d8\u91cf\u7684\u5b58\u50a8\u4e3b\u8981\u6709\u4e24\u79cd\u4f4d\u7f6e\uff0c\u6808\u5185\u5b58\u548c\u5806\u5185\u5b58\uff0c\u6808\u5185\u5b58\u5b58\u50a8\u57fa\u672c\u7c7b\u578b\u6570\u636e\u4ee5\u53ca\u5f15\u7528\u7c7b\u578b\u6570\u636e\u7684\u5185\u5b58\u5730\u5740\uff0c\u5806\u5185\u5b58\u50a8\u5b58\u5f15\u7528\u7c7b\u578b\u7684\u6570\u636e<\/p>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/17149730709e41a4.jpg\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2737\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/17149730709e41a4.jpg\" alt=\"17149730709e41a4\" width=\"988\" height=\"388\" \/><\/a><\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u6808\u5185\u5b58\u7684\u56de\u6536\uff1a\n<\/p><\/blockquote>\n<p style=\"margin: 1em 0px;\">\u6808\u5185\u5b58\u8c03\u7528\u6808\u4e0a\u4e0b\u6587\u5207\u6362\u540e\u5c31\u88ab\u56de\u6536\uff0c\u6bd4\u8f83\u7b80\u5355<\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u5806\u5185\u5b58\u7684\u56de\u6536\uff1a\n<\/p><\/blockquote>\n<p style=\"margin: 1em 0px;\">V8\u7684\u5806\u5185\u5b58\u5206\u4e3a\u65b0\u751f\u4ee3\u5185\u5b58\u548c\u8001\u751f\u4ee3\u5185\u5b58\uff0c\u65b0\u751f\u4ee3\u5185\u5b58\u662f\u4e34\u65f6\u5206\u914d\u7684\u5185\u5b58\uff0c\u5b58\u5728\u65f6\u95f4\u77ed\uff0c\u8001\u751f\u4ee3\u5185\u5b58\u5b58\u5728\u65f6\u95f4\u957f<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\u65b0\u751f\u4ee3\u5185\u5b58\u56de\u6536\u673a\u5236\uff1a\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u65b0\u751f\u4ee3\u5185\u5b58\u5bb9\u91cf\u5c0f\uff0c64\u4f4d\u7cfb\u7edf\u4e0b\u4ec5\u670932M\u3002\u65b0\u751f\u4ee3\u5185\u5b58\u5206\u4e3a<strong style=\"color: #4870ac;\">From\u3001To<\/strong>\u4e24\u90e8\u5206\uff0c\u8fdb\u884c\u5783\u573e\u56de\u6536\u65f6\uff0c\u5148\u626b\u63cfFrom\uff0c\u5c06\u975e\u5b58\u6d3b\u5bf9\u8c61\u56de\u6536\uff0c\u5c06\u5b58\u6d3b\u5bf9\u8c61\u987a\u5e8f\u590d\u5236\u5230To\u4e2d\uff0c\u4e4b\u540e\u8c03\u6362From\/To\uff0c\u7b49\u5f85\u4e0b\u4e00\u6b21\u56de\u6536<\/section>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u8001\u751f\u4ee3\u5185\u5b58\u56de\u6536\u673a\u5236\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><strong style=\"color: #4870ac;\">\u664b\u5347<\/strong>\uff1a\u5982\u679c\u65b0\u751f\u4ee3\u7684\u53d8\u91cf\u7ecf\u8fc7\u591a\u6b21\u56de\u6536\u4f9d\u7136\u5b58\u5728\uff0c\u90a3\u4e48\u5c31\u4f1a\u88ab\u653e\u5165\u8001\u751f\u4ee3\u5185\u5b58\u4e2d<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u6807\u8bb0\u6e05\u9664<\/strong>\uff1a\u8001\u751f\u4ee3\u5185\u5b58\u4f1a\u5148\u904d\u5386\u6240\u6709\u5bf9\u8c61\u5e76\u6253\u4e0a\u6807\u8bb0\uff0c\u7136\u540e\u5bf9\u6b63\u5728\u4f7f\u7528\u6216\u88ab\u5f3a\u5f15\u7528\u7684\u5bf9\u8c61\u53d6\u6d88\u6807\u8bb0\uff0c\u56de\u6536\u88ab\u6807\u8bb0\u7684\u5bf9\u8c61<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u6574\u7406\u5185\u5b58\u788e\u7247<\/strong>\uff1a\u628a\u5bf9\u8c61\u632a\u5230\u5185\u5b58\u7684\u4e00\u7aef<\/section>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u53c2\u8003\u8d44\u6599\uff1a<a href=\"https:\/\/juejin.im\/post\/5ad3f1156fb9a028b86e78be#heading-10\">\u804a\u804aV8\u5f15\u64ce\u7684\u5783\u573e\u56de\u6536<\/a>\n<\/p><\/blockquote>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">4. JS\u76f8\u8f83\u4e8eC++\u7b49\u8bed\u8a00\u4e3a\u4ec0\u4e48\u6162\uff0cV8\u505a\u4e86\u54ea\u4e9b\u4f18\u5316<\/h3>\n<ol style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem;\">\n<li>JS\u7684\u95ee\u9898\uff1a\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><strong style=\"color: #4870ac;\">\u52a8\u6001\u7c7b\u578b<\/strong>\uff1a\u5bfc\u81f4\u6bcf\u6b21\u5b58\u53d6\u5c5e\u6027\/\u5bfb\u6c42\u65b9\u6cd5\u65f6\u5019\uff0c\u90fd\u9700\u8981\u5148\u68c0\u67e5\u7c7b\u578b\uff1b\u6b64\u5916\u52a8\u6001\u7c7b\u578b\u4e5f\u5f88\u96be\u5728\u7f16\u8bd1\u9636\u6bb5\u8fdb\u884c\u4f18\u5316<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u5c5e\u6027\u5b58\u53d6<\/strong>\uff1aC++\/Java\u7b49\u8bed\u8a00\u4e2d\u65b9\u6cd5\u3001\u5c5e\u6027\u662f\u5b58\u50a8\u5728\u6570\u7ec4\u4e2d\u7684\uff0c\u4ec5\u9700\u6570\u7ec4\u4f4d\u79fb\u5c31\u53ef\u4ee5\u83b7\u53d6\uff0c\u800cJS\u5b58\u50a8\u5728\u5bf9\u8c61\u4e2d\uff0c\u6bcf\u6b21\u83b7\u53d6\u90fd\u8981\u8fdb\u884c\u54c8\u5e0c\u67e5\u8be2<\/section>\n<\/li>\n<\/ul>\n<\/li>\n<li>V8\u7684\u4f18\u5316\uff1a\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><strong style=\"color: #4870ac;\">\u4f18\u5316JIT(\u5373\u65f6\u7f16\u8bd1)<\/strong>\uff1a\u76f8\u8f83\u4e8eC++\/Java\u8fd9\u7c7b\u7f16\u8bd1\u578b\u8bed\u8a00\uff0cJS\u4e00\u8fb9\u89e3\u91ca\u4e00\u8fb9\u6267\u884c\uff0c\u6548\u7387\u4f4e\u3002V8\u5bf9\u8fd9\u4e2a\u8fc7\u7a0b\u8fdb\u884c\u4e86\u4f18\u5316\uff1a\u5982\u679c\u4e00\u6bb5\u4ee3\u7801\u88ab\u6267\u884c\u591a\u6b21\uff0c\u90a3\u4e48V8\u4f1a\u628a\u8fd9\u6bb5\u4ee3\u7801\u8f6c\u5316\u4e3a\u673a\u5668\u7801\u7f13\u5b58\u4e0b\u6765\uff0c\u4e0b\u6b21\u8fd0\u884c\u65f6\u76f4\u63a5\u4f7f\u7528\u673a\u5668\u7801\u3002<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u9690\u85cf\u7c7b<\/strong>\uff1a\u5bf9\u4e8eC++\u8fd9\u7c7b\u8bed\u8a00\u6765\u8bf4\uff0c\u4ec5\u9700\u51e0\u4e2a\u6307\u4ee4\u5c31\u80fd\u901a\u8fc7\u504f\u79fb\u91cf\u83b7\u53d6\u53d8\u91cf\u4fe1\u606f\uff0c\u800cJS\u9700\u8981\u8fdb\u884c\u5b57\u7b26\u4e32\u5339\u914d\uff0c\u6548\u7387\u4f4e\uff0cV8\u501f\u7528\u4e86\u7c7b\u548c\u504f\u79fb\u4f4d\u7f6e\u7684\u601d\u60f3\uff0c\u5c06\u5bf9\u8c61\u5212\u5206\u6210\u4e0d\u540c\u7684\u7ec4\uff0c\u5373\u9690\u85cf\u7c7b<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u5185\u5d4c\u7f13\u5b58<\/strong>\uff1a\u5373\u7f13\u5b58\u5bf9\u8c61\u67e5\u8be2\u7684\u7ed3\u679c\u3002\u5e38\u89c4\u67e5\u8be2\u8fc7\u7a0b\u662f\uff1a\u83b7\u53d6\u9690\u85cf\u7c7b\u5730\u5740 -&gt; \u6839\u636e\u5c5e\u6027\u540d\u67e5\u627e\u504f\u79fb\u503c -&gt; \u8ba1\u7b97\u8be5\u5c5e\u6027\u5730\u5740\uff0c\u5185\u5d4c\u7f13\u5b58\u5c31\u662f\u5bf9\u8fd9\u4e00\u8fc7\u7a0b\u7ed3\u679c\u7684\u7f13\u5b58<\/section>\n<\/li>\n<li>\n<section><strong style=\"color: #4870ac;\">\u5783\u573e\u56de\u6536\u7ba1\u7406<\/strong>\uff1a\u4e0a\u6587\u5df2\u4ecb\u7ecd<\/section>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1714a1f7c054c657.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2739\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/1714a1f7c054c657.png\" alt=\"1714a1f7c054c657\" width=\"2124\" height=\"1368\" \/><\/a><\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\"><p>\n\u53c2\u8003\u8d44\u6599\uff1a<a href=\"https:\/\/zhuanlan.zhihu.com\/p\/27628685\">\u4e3a\u4ec0\u4e48V8\u5f15\u64ce\u8fd9\u4e48\u5feb\uff1f<\/a>\n<\/p><\/blockquote>\n<ol style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem;\">\n<li>\n<section>\u94fe\u63a5\uff1a<a class=\"url\" href=\"https:\/\/juejin.im\/post\/5e8b261ae51d4546c0382ab4\" target=\"_blank\">https:\/\/juejin.im\/post\/5e8b261ae51d4546c0382ab4<\/a><\/section>\n<\/li>\n<\/ol>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a\u57fa\u7840\u9898\u4f1a\u624b\u5199\uff0c\u9762\u5411\u5bf9\u8c61\u9898\u80fd\u8bb2\u6e05\u539f\u578b\u94fe\u7ee7\u627f\u548c\u5bc4\u751f\u7ec4\u5408\u7ee7\u627f\uff0c\u5f15\u64ce\u9898\u80fd\u8bf4\u51fa V8 \u5982\u4f55\u7f16\u8bd1\u548c\u56de\u6536\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u4ece JS \u57fa\u7840\u3001\u9762\u5411\u5bf9\u8c61\u548c V8 \u4e09\u4e2a\u65b9\u5411\u6536\u524d\u7aef\u8fdb\u9636\uff1aES5 \u6a21\u62df let\/const\uff0c\u624b\u5199 call\/a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[109,105],"tags":[150],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2727"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2727"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2727\/revisions"}],"predecessor-version":[{"id":2746,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2727\/revisions\/2746"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}