{"id":148,"date":"2022-08-18T15:31:41","date_gmt":"2022-08-18T07:31:41","guid":{"rendered":"http:\/\/weboob.top\/blog\/?p=148"},"modified":"2022-08-18T15:31:41","modified_gmt":"2022-08-18T07:31:41","slug":"javascript%e5%87%bd%e6%95%b0%e4%b8%adapply%e3%80%81call%e3%80%81bind%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"http:\/\/blog.weboob.top\/?p=148","title":{"rendered":"Javascript\u51fd\u6570\u4e2dapply\u3001call\u3001bind\u89e3\u6790"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/baijiahao.baidu.com\/s?id=1728527150329407234&amp;wfr=spider&amp;for=pc\">\u539f\u6587\u5730\u5740<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"%E4%B8%80%E4%BD%9C%E7%94%A8\">\u4e00\u3001\u4f5c\u7528<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">call\u3001apply\u3001bind\u4f5c\u7528\u662f\u6539\u53d8\u51fd\u6570\u6267\u884c\u65f6\u7684\u4e0a\u4e0b\u6587\uff0c\u7b80\u800c\u8a00\u4e4b\u5c31\u662f\u6539\u53d8\u51fd\u6570\u8fd0\u884c\u65f6\u7684this\u6307\u5411<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">call\u3001apply\u3001bind\u662fFunction.prototype\u4e0b\u7684\u65b9\u6cd5\uff0c\u90fd\u662f\u7528\u4e8e\u6539\u53d8\u51fd\u6570\u8fd0\u884c\u65f6\u4e0a\u4e0b\u6587\uff0c\u6700\u7ec8\u7684\u8fd4\u56de\u503c\u662f\u4f60\u8c03\u7528\u7684\u65b9\u6cd5\u7684\u8fd4\u56de\u503c\uff0c\u82e5\u8be5\u65b9\u6cd5\u6ca1\u6709\u8fd4\u56de\u503c\uff0c\u5219\u8fd4\u56deundefined\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"apply\">apply<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">apply\u65b9\u6cd5 \u4e5f\u662f\u6539\u53d8this\u7684\u6307\u5411, \u7acb\u5373\u6267\u884c, \u4e0ecall\u65b9\u6cd5\u4e0d\u540c\u7684\u662f apply\u65b9\u6cd5\u4f20\u5165\u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u6570\u7ec4<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"%E8%AF%AD%E6%B3%95\">\u8bed\u6cd5<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><code>apply([thisObj[,argArray]])<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5b9a\u4e49\uff1a\u5e94\u7528\u67d0\u4e00\u5bf9\u8c61\u7684\u4e00\u4e2a\u65b9\u6cd5\uff0c\u7528\u53e6\u4e00\u4e2a\u5bf9\u8c61\u66ff\u6362\u5f53\u524d\u5bf9\u8c61\u3002<\/li><li>\u8bf4\u660e\uff1a\u5982\u679c argArray \u4e0d\u662f\u4e00\u4e2a\u6709\u6548\u7684\u6570\u7ec4\u6216\u8005\u4e0d\u662f arguments \u5bf9\u8c61\uff0c\u90a3\u4e48\u5c06\u5bfc\u81f4\u4e00\u4e2a TypeError\u3002 \u5982\u679c\u6ca1\u6709\u63d0\u4f9b argArray \u548c thisObj \u4efb\u4f55\u4e00\u4e2a\u53c2\u6570\uff0c\u90a3\u4e48 Global \u5bf9\u8c61\u5c06\u88ab\u7528\u4f5c thisObj\uff0c\u5e76\u4e14\u65e0\u6cd5\u88ab\u4f20\u9012\u4efb\u4f55\u53c2\u6570\u3002<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">call \u548c apply\u7684\u533a\u522b \u5bf9\u4e8e apply\u3001call \u4e8c\u8005\u800c\u8a00\uff0c\u4f5c\u7528\u5b8c\u5168\u4e00\u6837\uff0c\u53ea\u662f\u63a5\u53d7\u53c2\u6570\u7684\u65b9\u5f0f\u4e0d\u592a\u4e00\u6837\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528 apply\uff0c \u4f60\u53ef\u4ee5\u7ee7\u627f\u5176\u4ed6\u5bf9\u8c61\u7684\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const max = Math.max.apply(null, &#91;1, 2, 3, 4, 5, 6, 7, 8]);\nconsole.log(max); <em>\/\/ \u8f93\u51fa8<\/em>\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\u8fd9\u91ccapply()\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u662fnull\uff0c\u5728\u975e\u4e25\u683c\u6a21\u5f0f\u4e0b\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3anull\u6216\u8005undefined\u65f6\u4f1a\u81ea\u52a8\u66ff\u6362\u4e3a\u6307\u5411\u5168\u5c40\u5bf9\u8c61\uff0c apply()\u7684\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u6570\u7ec4\u6216\u7c7b\u6570\u7ec4\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"call\">call<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">call \u65b9\u6cd5 \u6539\u53d8this\u7684\u6307\u5411, \u7acb\u5373\u6267\u884c\u51fd\u6570, \u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u8868\u793a\u8981\u7ed1\u5b9a\u7684\u5bf9\u8c61, \u5982\u679c\u8c03\u7528\u65f6\u4e0d\u4f20\u53c2, \u6bd4\u5982call()call(null)call(undefined)\u8fd9\u4e09\u79cd\u7684this\u90fd\u6307\u5411window<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5b9a\u4e49\uff1a\u8c03\u7528\u4e00\u4e2a\u5bf9\u8c61\u7684\u4e00\u4e2a\u65b9\u6cd5\uff0c\u4ee5\u53e6\u4e00\u4e2a\u5bf9\u8c61\u66ff\u6362\u5f53\u524d\u5bf9\u8c61\u3002<\/li><li>\u8bf4\u660e\uff1a call \u65b9\u6cd5\u53ef\u4ee5\u7528\u6765\u4ee3\u66ff\u53e6\u4e00\u4e2a\u5bf9\u8c61\u8c03\u7528\u4e00\u4e2a\u65b9\u6cd5\u3002 call \u65b9\u6cd5\u53ef\u5c06\u4e00\u4e2a\u51fd\u6570\u7684\u5bf9\u8c61\u4e0a\u4e0b\u6587\u4ece\u521d\u59cb\u7684\u4e0a\u4e0b\u6587\u6539\u53d8\u4e3a\u7531 thisObj \u6307\u5b9a\u7684\u65b0\u5bf9\u8c61\u3002<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"e8afade6b395-1\">\u8bed\u6cd5<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">call([thisObj[,arg1[, arg2[, [,.argN]]]]])<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">thisObj\u7684\u53d6\u503c\u6709\u4ee5\u4e0b4\u79cd\u60c5\u51b5\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u4e0d\u4f20\uff0c\u6216\u8005\u4f20null,undefined\uff0c \u51fd\u6570\u4e2d\u7684this\u6307\u5411window\u5bf9\u8c61<\/li><li>\u4f20\u9012\u53e6\u4e00\u4e2a\u51fd\u6570\u7684\u51fd\u6570\u540d\uff0c\u51fd\u6570\u4e2d\u7684this\u6307\u5411\u8fd9\u4e2a\u51fd\u6570\u7684\u5f15\u7528<\/li><li>\u4f20\u9012\u5b57\u7b26\u4e32\u3001\u6570\u503c\u6216\u5e03\u5c14\u7c7b\u578b\u7b49\u57fa\u7840\u7c7b\u578b\uff0c\u51fd\u6570\u4e2d\u7684this\u6307\u5411\u5176\u5bf9\u5e94\u7684\u5305\u88c5\u5bf9\u8c61\uff0c\u5982 String\u3001Number\u3001Boolean<\/li><li>\u4f20\u9012\u4e00\u4e2a\u5bf9\u8c61\uff0c\u51fd\u6570\u4e2d\u7684this\u6307\u5411\u8fd9\u4e2a\u5bf9\u8c61<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">call()\u662fapply()\u7684\u4e00\u9897\u8bed\u6cd5\u7cd6\uff0c\u4f5c\u7528\u548c apply() \u4e00\u6837\uff0c\u540c\u6837\u53ef\u5b9e\u73b0\u7ee7\u627f\uff0c\u552f\u4e00\u7684\u533a\u522b\u5c31\u5728\u4e8ecall()\u63a5\u6536\u7684\u662f\u53c2\u6570\u5217\u8868\uff0c\u800capply()\u5219\u63a5\u6536\u53c2\u6570\u6570\u7ec4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const max = Math.max.call(null, &#91;1, 2, 3, 4, 5, 6, 7, 8]);\nconsole.log(max); <em>\/\/ \u8f93\u51fa8<\/em>\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"bind\">bind<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">bind\u65b9\u6cd5 \u4e0e\u4ee5\u4e0a\u65b9\u6cd5\u4e0d\u540c\u7684\u662f, \u5b83\u4e0d\u662f\u4e00\u4e2a\u7acb\u5373\u6267\u884c\u7684\u65b9\u6cd5, \u8fd4\u56de\u4e00\u4e2a\u51fd\u6570<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">bind()\u7684\u4f5c\u7528\u4e0ecall()\u548capply()\u4e00\u6837\uff0c\u90fd\u662f\u53ef\u4ee5\u6539\u53d8\u51fd\u6570\u8fd0\u884c\u65f6\u4e0a\u4e0b\u6587\uff0c\u533a\u522b\u662fcall()\u548capply()\u5728\u8c03\u7528\u51fd\u6570\u4e4b\u540e\u4f1a\u7acb\u5373\u6267\u884c\uff0c\u800cbind()\u65b9\u6cd5\u8c03\u7528\u5e76\u6539\u53d8\u51fd\u6570\u8fd0\u884c\u65f6\u4e0a\u4e0b\u6587\u540e\uff0c\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u51fd\u6570\uff0c\u4f9b\u6211\u4eec\u9700\u8981\u65f6\u518d\u8c03\u7528\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const person = {\n    name: 'person',\n    getName: function() { return this.name;  }\n};\nconst boy = { name: 'twy'}\n\n<em>\/\/ bind()\u8fd4\u56de\u4e00\u4e2a\u65b0\u51fd\u6570\uff0c\u4f9b\u4ee5\u540e\u8c03\uff0c\u76ee\u524d\u662f\u4e0d\u6267\u884c\u7684<\/em>\nconst getName = person.getName.bind(boy);\n<em>\/\/ \u73b0\u5728\u624d\u5f00\u59cb\u6267\u884c<\/em>\nconsole.log(getName()); <em>\/\/ \u8f93\u51fawy<\/em>\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"%E9%82%A3%E4%B9%88%E4%BB%80%E4%B9%88%E6%83%85%E5%86%B5%E4%B8%8B%E9%9C%80%E8%A6%81%E6%94%B9%E5%8F%98this%E7%9A%84%E6%8C%87%E5%90%91%E5%91%A2%E4%B8%8B%E9%9D%A2%E4%B8%BE%E4%B8%AA%E4%BE%8B%E5%AD%90\">\u90a3\u4e48\u4ec0\u4e48\u60c5\u51b5\u4e0b\u9700\u8981\u6539\u53d8this\u7684\u6307\u5411\u5462\uff1f\u4e0b\u9762\u4e3e\u4e2a\u4f8b\u5b50<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>var name=\"lucy\";\nconst obj={\n    name:\"martin\",\n    say:function () { console.log(this.name); }\n};\n\nobj.say();  <em>\/\/martin\uff0cthis\u6307\u5411obj\u5bf9\u8c61<\/em>\nsetTimeout(obj.say, 0); <em>\/\/lucy\uff0cthis\u6307\u5411window\u5bf9\u8c61<\/em>\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u4e0a\u9762\u53ef\u4ee5\u770b\u5230\uff0c\u6b63\u5e38\u60c5\u51b5say\u65b9\u6cd5\u8f93\u51famartin<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f46\u662f\u6211\u4eec\u628asay\u653e\u5728setTimeout\u65b9\u6cd5\u4e2d\uff0c\u5728\u5b9a\u65f6\u5668\u4e2d\u662f\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u6765\u6267\u884c\u7684\uff0c\u56e0\u6b64\u56de\u5230\u4e3b\u6808\u6267\u884c\u65f6\u662f\u5728\u5168\u5c40\u6267\u884c\u4e0a\u4e0b\u6587\u7684\u73af\u5883\u4e2d\u6267\u884c\u7684\uff0c\u8fd9\u65f6\u5019this\u6307\u5411window\uff0c\u6240\u4ee5\u8f93\u51faluck<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u5b9e\u9645\u9700\u8981\u7684\u662fthis\u6307\u5411obj\u5bf9\u8c61\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u8be5\u6539\u53d8this\u6307\u5411\u4e86<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">setTimeout(obj.say.bind(obj),0); \/\/martin\uff0cthis\u6307\u5411obj\u5bf9\u8c61<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"%E4%BA%8C%E5%8C%BA%E5%88%AB\">\u4e8c\u3001\u533a\u522b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u518d\u6765\u770b\u770bapply\u3001call\u3001bind\u7684\u4f7f\u7528<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"apply-1\">apply<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">apply\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662fthis\u7684\u6307\u5411\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u51fd\u6570\u63a5\u53d7\u7684\u53c2\u6570\uff0c\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u4f20\u5165<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6539\u53d8this\u6307\u5411\u540e\u539f\u51fd\u6570\u4f1a\u7acb\u5373\u6267\u884c\uff0c\u4e14\u6b64\u65b9\u6cd5\u53ea\u662f\u4e34\u65f6\u6539\u53d8this\u6307\u5411\u4e00\u6b21<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function fn(...args){\n    console.log(this,args);\n}\n\nlet obj = { myname:\"\u5f20\u4e09\" };\n\nfn.apply(obj, &#91;1,2]); <em>\/\/ this\u4f1a\u53d8\u6210\u4f20\u5165\u7684obj\uff0c\u4f20\u5165\u7684\u53c2\u6570\u5fc5\u987b\u662f\u4e00\u4e2a\u6570\u7ec4\uff1b<\/em>\nfn(1,2) <em>\/\/ this\u6307\u5411window<\/em>\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3anull\u3001undefined\u7684\u65f6\u5019\uff0c\u9ed8\u8ba4\u6307\u5411window(\u5728\u6d4f\u89c8\u5668\u4e2d)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fn.apply(null, &#91;1,2]); <em>\/\/ this\u6307\u5411window<\/em>\nfn.apply(undefined, &#91;1,2]); <em>\/\/ this\u6307\u5411window<\/em>\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"call-1\">call<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">call\u65b9\u6cd5\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e5f\u662fthis\u7684\u6307\u5411\uff0c\u540e\u9762\u4f20\u5165\u7684\u662f\u4e00\u4e2a\u53c2\u6570\u5217\u8868<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ddfapply\u4e00\u6837\uff0c\u6539\u53d8this\u6307\u5411\u540e\u539f\u51fd\u6570\u4f1a\u7acb\u5373\u6267\u884c\uff0c\u4e14\u6b64\u65b9\u6cd5\u53ea\u662f\u4e34\u65f6\u6539\u53d8this\u6307\u5411\u4e00\u6b21<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function fn(...args){\n    console.log(this, args);\n}\nlet obj = { myname:\"\u5f20\u4e09\" };\nfn.call(obj, 1, 2); <em>\/\/ this\u4f1a\u53d8\u6210\u4f20\u5165\u7684obj\uff0c\u4f20\u5165\u7684\u53c2\u6570\u9017\u53f7\u5206\u5272<\/em>\nfn(1,2) <em>\/\/ this\u6307\u5411window<\/em>\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u6837\u7684\uff0c\u5f53\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3anull\u3001undefined\u7684\u65f6\u5019\uff0c\u9ed8\u8ba4\u6307\u5411window(\u5728\u6d4f\u89c8\u5668\u4e2d)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fn.call( null, &#91;1,2] ); <em>\/\/ this\u6307\u5411window<\/em>\nfn.call( undefined, &#91;1,2] ); <em>\/\/ this\u6307\u5411window<\/em>\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"bind-1\">bind<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">bind\u65b9\u6cd5\u548ccall\u5f88\u76f8\u4f3c\uff0c\u7b2c\u4e00\u53c2\u6570\u4e5f\u662fthis\u7684\u6307\u5411\uff0c\u540e\u9762\u4f20\u5165\u7684\u4e5f\u662f\u4e00\u4e2a\u53c2\u6570\u5217\u8868(\u4f46\u662f\u8fd9\u4e2a\u53c2\u6570\u5217\u8868\u53ef\u4ee5\u5206\u591a\u6b21\u4f20\u5165)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6539\u53d8this\u6307\u5411\u540e\u4e0d\u4f1a\u7acb\u5373\u6267\u884c\uff0c\u800c\u662f\u8fd4\u56de\u4e00\u4e2a<code>\u6c38\u4e45\u6539\u53d8this<\/code>\u6307\u5411\u7684\u51fd\u6570<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function fn(...args){\n    console.log(this,args);\n}\nlet obj = { myname:\"\u5f20\u4e09\" };\nconst bindFn = fn.bind(obj); <em>\/\/ this \u4e5f\u4f1a\u53d8\u6210\u4f20\u5165\u7684obj \uff0cbind\u4e0d\u662f\u7acb\u5373\u6267\u884c\u9700\u8981\u6267\u884c\u4e00\u6b21<\/em>\nbindFn(1,2) <em>\/\/ this\u6307\u5411obj<\/em>\nfn(1,2) <em>\/\/ this\u6307\u5411window<\/em>\nbindFn(1,2) <em>\/\/ this\u6307\u5411obj<\/em>\nfn(1,2) <em>\/\/ this\u6307\u5411window<\/em>\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"%E5%B0%8F%E7%BB%93\">\u5c0f\u7ed3<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ece\u4e0a\u9762\u53ef\u4ee5\u770b\u5230\uff0capply\u3001call\u3001bind\u4e09\u8005\u7684\u533a\u522b\u5728\u4e8e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4e09\u8005\u90fd\u53ef\u4ee5\u6539\u53d8\u51fd\u6570\u7684this\u5bf9\u8c61\u6307\u5411\uff0c\u90fd\u662f\u7528\u6765\u6539\u53d8\u51fd\u6570\u6267\u884c\u65f6\u7684\u4e0a\u4e0b\u6587\uff0c\u53ef\u501f\u52a9\u5b83\u4eec\u5b9e\u73b0\u7ee7\u627f\uff1b<\/li><li>\u4e09\u8005\u7b2c\u4e00\u4e2a\u53c2\u6570\u90fd\u662fthis\u8981\u6307\u5411\u7684\u5bf9\u8c61\uff0c\u5982\u679c\u5982\u679c\u6ca1\u6709\u8fd9\u4e2a\u53c2\u6570\u6216\u53c2\u6570\u4e3aundefined\u6216null\uff0c\u5219\u9ed8\u8ba4\u6307\u5411\u5168\u5c40window<\/li><li>\u4e09\u8005\u90fd\u53ef\u4ee5\u4f20\u53c2\uff0c\u4f46\u662fapply\u662f\u6570\u7ec4\uff0c\u800ccall\u662f\u53c2\u6570\u5217\u8868\uff0c\u4e14apply\u548ccall\u662f\u4e00\u6b21\u6027\u4f20\u5165\u53c2\u6570\uff0c\u800cbind\u53ef\u4ee5\u5206\u4e3a\u591a\u6b21\u4f20\u5165<\/li><li>call()\u548capply()\u552f\u4e00\u533a\u522b\u662f\u53c2\u6570\u4e0d\u4e00\u6837\uff0ccall()\u662fapply()\u7684\u8bed\u6cd5\u7cd6\uff1b<\/li><li>bind\u662f\u8fd4\u56de\u7ed1\u5b9athis\u4e4b\u540e\u7684\u51fd\u6570\uff0c\u4e00\u4e2a\u65b0\u51fd\u6570\uff0c\u800capply\u3001call \u5219\u662f\u7acb\u5373\u6267\u884c\u8c03\u7528\u3002<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"%E4%B8%89%E5%A6%82%E4%BD%95%E9%80%89%E7%94%A8\">\u4e09\u3001\u5982\u4f55\u9009\u7528<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5982\u679c\u4e0d\u9700\u8981\u5173\u5fc3\u5177\u4f53\u6709\u591a\u5c11\u53c2\u6570\u88ab\u4f20\u5165\u51fd\u6570\uff0c\u9009\u7528apply()\uff1b<\/li><li>\u5982\u679c\u786e\u5b9a\u51fd\u6570\u53ef\u63a5\u6536\u591a\u5c11\u4e2a\u53c2\u6570\uff0c\u5e76\u4e14\u60f3\u4e00\u76ee\u4e86\u7136\u8868\u8fbe\u5f62\u53c2\u548c\u5b9e\u53c2\u7684\u5bf9\u5e94\u5173\u7cfb\uff0c\u7528call()\uff1b<\/li><li>\u5982\u679c\u6211\u4eec\u60f3\u8981\u5c06\u6765\u518d\u8c03\u7528\u65b9\u6cd5\uff0c\u4e0d\u9700\u7acb\u5373\u5f97\u5230\u51fd\u6570\u8fd4\u56de\u7ed3\u679c\uff0c\u5219\u4f7f\u7528bind();<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>JS\u4e2dFunction.prototype\u4e2d\u7684apply\u3001call\u3001bind\u89e3\u6790<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,1],"tags":[16,17,18,22,26],"class_list":["post-148","post","type-post","status-publish","format-standard","hentry","category-js","category-uncategorized","tag-apply","tag-bind","tag-call","tag-javascript","tag-this"],"_links":{"self":[{"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=148"}],"version-history":[{"count":0,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=\/wp\/v2\/posts\/148\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.weboob.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.weboob.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}