{"id":161584,"date":"2024-05-08T13:54:37","date_gmt":"2024-05-08T05:54:37","guid":{"rendered":""},"modified":"2024-05-08T13:54:45","modified_gmt":"2024-05-08T05:54:45","slug":"%e5%85%b3%e4%ba%8ejavascript%e4%b8%adinstanceof","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/161584.html","title":{"rendered":"\u5173\u4e8ejavascript\u4e2dinstanceof"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26224236\/777265a2-321e-4da9-9fa0-95c78eebe00c.webp\" alt=\"\u5173\u4e8ejavascript\u4e2dinstanceof\" \/><\/p>\n<p><p>JavaScript\u4e2d\u7684<code>instanceof<\/code>\u64cd\u4f5c\u7b26\u662f\u7528\u4e8e\u6d4b\u8bd5\u6784\u9020\u51fd\u6570\u7684<code>prototype<\/code>\u5c5e\u6027\u662f\u5426\u51fa\u73b0\u5728\u67d0\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\u7684\u539f\u578b\u94fe\u4e0a\u3002<strong>\u6b64\u64cd\u4f5c\u7b26\u68c0\u67e5\u4e00\u4e2a\u5bf9\u8c61\u662f\u5426\u662f\u53e6\u4e00\u4e2a\u5bf9\u8c61\u7684\u5b9e\u4f8b<\/strong>\u3001<strong>\u5224\u65ad\u5bf9\u8c61\u4e0e\u6784\u9020\u51fd\u6570\u4e4b\u95f4\u7684\u5173\u7cfb<\/strong>\u3001\u5e76<strong>\u7528\u4e8e\u9a8c\u8bc1\u5bf9\u8c61\u662f\u5426\u5c5e\u4e8e\u7279\u5b9a\u7684\u7c7b\u6216\u6570\u636e\u7ed3\u6784<\/strong>\u3002\u4f8b\u5982\uff0c<code>new Date()<\/code>\u521b\u5efa\u7684\u5bf9\u8c61\u4f7f\u7528<code>instanceof Date<\/code>\u5c06\u8fd4\u56de<code>true<\/code>\uff0c\u56e0\u4e3a<code>Date.prototype<\/code>\u662f\u5176\u539f\u578b\u94fe\u4e0a\u7684\u4e00\u4e2a\u6210\u5458\u3002\u6269\u5c55\u8fd9\u4e00\u70b9\uff0c\u4f7f\u7528<code>instanceof<\/code>\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u8bc6\u522b\u590d\u6742\u7684\u7ee7\u627f\u7ed3\u6784\u4e2d\uff0c\u5bf9\u8c61\u662f\u5426\u6d3e\u751f\u81ea\u7279\u5b9a\u7684\u7236\u7c7b\u6216\u6784\u9020\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001INSTANCEOF\u7684\u5de5\u4f5c\u539f\u7406<\/h3>\n<\/p>\n<p><p><strong>instanceof<\/strong> \u64cd\u4f5c\u7b26\u7528\u6765\u6d4b\u8bd5\u4e00\u4e2a\u5bf9\u8c61\u5728\u5176\u539f\u578b\u94fe\u4e0a\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u6784\u9020\u51fd\u6570\u7684 <code>prototype<\/code> \u5c5e\u6027\u3002\u5b83\u8fd4\u56de\u4e00\u4e2a\u5e03\u5c14\u503c\uff0c\u6307\u793a\u5bf9\u8c61\u662f\u5426\u662f\u7279\u5b9a\u6784\u9020\u51fd\u6570\u7684\u5b9e\u4f8b\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5047\u8bbe\u6709\u4e00\u4e2a\u6784\u9020\u51fd\u6570 <code>Constructor<\/code> \u548c\u4e00\u4e2a\u5bf9\u8c61\u5b9e\u4f8b <code>instance<\/code>\u3002\u5f53\u6267\u884c <code>instance instanceof Constructor<\/code> \u65f6\uff0cJavaScript \u5f15\u64ce\u5c06\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4:<\/p>\n<\/p>\n<ol>\n<li>\u83b7\u53d6 <code>Constructor.prototype<\/code>\uff0c\u5373\u6784\u9020\u51fd\u6570\u7684\u539f\u578b\u3002<\/li>\n<li>\u83b7\u53d6 <code>instance<\/code> \u7684\u539f\u578b\u94fe\u3002<\/li>\n<li>\u6bd4\u8f83 <code>Constructor.prototype<\/code> \u662f\u5426\u5b58\u5728\u4e8e <code>instance<\/code> \u7684\u539f\u578b\u94fe\u4e0a\u3002<\/li>\n<li>\u5982\u679c\u5b58\u5728\uff0c\u8fd4\u56de <code>true<\/code>\uff1b\u5982\u679c\u4e0d\u5728\u539f\u578b\u94fe\u4e0a\uff0c\u8fd4\u56de <code>false<\/code>\u3002<\/li>\n<\/ol>\n<p><h4>\u8be6\u89e3\u539f\u578b\u94fe<\/h4>\n<\/p>\n<p><p>\u6bcf\u4e2aJavaScript\u5bf9\u8c61\u90fd\u6709\u4e00\u4e2a\u5185\u7f6e\u7684\u5c5e\u6027\uff0c\u79f0\u4e3a <code>[[Prototype]]<\/code>\uff0c\u901a\u5e38\u88ab\u79f0\u4f5c\u5bf9\u8c61\u7684\u539f\u578b\u3002\u8fd9\u4e2a\u5c5e\u6027\u662f\u4e00\u4e2a\u6307\u5411\u53e6\u4e00\u4e2a\u5bf9\u8c61\u7684\u5f15\u7528\uff0c\u800c\u90a3\u4e2a\u5bf9\u8c61\u5305\u542b\u53ef\u4ee5\u88ab\u6240\u6709\u76f8\u540c\u7c7b\u578b\u7684\u5b9e\u4f8b\u5171\u4eab\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u7ee7\u627f\u662f\u901a\u8fc7\u539f\u578b\u94fe\u5b9e\u73b0\u7684\uff0c\u8fd9\u662f\u4e00\u79cd\u5bf9\u8c61\u6307\u5411\u53e6\u4e00\u4e2a\u5bf9\u8c61\u7684\u65b9\u5f0f\uff0c\u4f7f\u5f97\u5bf9\u8c61\u53ef\u4ee5\u7ee7\u627f\u53e6\u4e00\u4e2a\u5bf9\u8c61\u7684\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001INSTANCEOF\u7684\u5e38\u89c1\u7528\u9014<\/h3>\n<\/p>\n<p><p><strong>instanceof<\/strong> \u5728\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u4e2d\u975e\u5e38\u6709\u7528\uff0c\u7279\u522b\u662f\u5f53\u5904\u7406\u591a\u6001\u6027\u548c\u7ee7\u627f\u65f6\u3002<\/p>\n<\/p>\n<p><h4>\u7c7b\u578b\u68c0\u67e5<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528 <strong>instanceof<\/strong> \u53ef\u4ee5\u786e\u5b9a\u4e00\u4e2a\u5bf9\u8c61\u662f\u5426\u662f\u7279\u5b9a\u7c7b\u578b\u7684\u5b9e\u4f8b\u3002\u8fd9\u5728\u9700\u8981\u6839\u636e\u5bf9\u8c61\u7c7b\u578b\u6765\u51b3\u5b9a\u4e0d\u540c\u7684\u884c\u4e3a\u65f6\u5c24\u5176\u6709\u7528\uff0c\u6bd4\u5982\u5728\u51fd\u6570\u91cd\u8f7d\u6216\u63d0\u4f9b\u7c7b\u578b\u7279\u5b9a\u7684\u529f\u80fd\u65f6\u3002<\/p>\n<\/p>\n<p><h4>\u65ad\u8a00\u6d4b\u8bd5<\/h4>\n<\/p>\n<p><p>\u5728\u5355\u5143\u6d4b\u8bd5\u4e2d\uff0c <strong>instanceof<\/strong> \u53ef\u4ee5\u7528\u6765\u6d4b\u8bd5\u5bf9\u8c61\u662f\u5426\u5c5e\u4e8e\u9884\u671f\u7684\u7c7b\u578b\u3002\u8fd9\u6709\u52a9\u4e8e\u9a8c\u8bc1\u5bf9\u8c61\u521b\u5efa\u548c\u7c7b\u7ee7\u627f\u662f\u5426\u6309\u9884\u671f\u5de5\u4f5c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001INSTANCEOF\u4e0e\u7c7b\u578b\u68c0\u6d4b<\/h3>\n<\/p>\n<p><p>\u5c3d\u7ba1 <strong>instanceof<\/strong> \u662f\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u5b83\u4e0d\u80fd\u68c0\u6d4b\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff08\u4f8b\u5982\uff0cstring\u3001number\u548cboolean\uff09\u3002\u5728JavaScript\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>typeof<\/code> \u64cd\u4f5c\u7b26\u6765\u68c0\u6d4b\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u4f46\u662f\u5bf9\u4e8e\u5bf9\u8c61\u7c7b\u578b\uff0c<code>typeof<\/code> \u5374\u6ca1\u6709 <code>instanceof<\/code> \u51c6\u786e\u3002<\/p>\n<\/p>\n<p><h4>\u533a\u522b\u4e8etypeof<\/h4>\n<\/p>\n<p><p><code>typeof<\/code>\u64cd\u4f5c\u7b26\u8fd4\u56de\u4e00\u4e2a\u8868\u793a\u53d8\u91cf\u6216\u8868\u8fbe\u5f0f\u6570\u636e\u7c7b\u578b\u7684\u5b57\u7b26\u4e32\u3002\u4e0e <strong>instanceof<\/strong> \u4e0d\u540c\uff0c <code>typeof<\/code> \u5bf9\u5bf9\u8c61\u7c7b\u578b\u7684\u8fa8\u8bc6\u975e\u5e38\u6709\u9650\uff0c\u65e0\u6cd5\u5177\u4f53\u533a\u5206Array\u3001Date\u7b49\u7c7b\u578b\u3002<\/p>\n<\/p>\n<p><h4>\u57fa\u672c\u7c7b\u578b\u7684\u68c0\u6d4b<\/h4>\n<\/p>\n<p><p>\u5bf9\u4e8e\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>typeof<\/code> \u800c\u4e0d\u662f <strong>instanceof<\/strong>\u3002\u4f8b\u5982\uff0c<code>typeof &quot;Hello World&quot;<\/code> \u5c06\u8fd4\u56de <code>&quot;string&quot;<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001INSTANCEOF\u7684\u5c40\u9650\u6027<\/h3>\n<\/p>\n<p><p>\u5c3d\u7ba1 <strong>instanceof<\/strong> \u662f\u68c0\u6d4b\u5bf9\u8c61\u7c7b\u578b\u7684\u6709\u529b\u5de5\u5177\uff0c\u4f46\u5b83\u4e5f\u6709\u81ea\u5df1\u7684\u9650\u5236\u3002<\/p>\n<\/p>\n<p><h4>\u4e0d\u540c\u6267\u884c\u4e0a\u4e0b\u6587<\/h4>\n<\/p>\n<p><p>\u5f53\u6d89\u53ca\u5230\u591a\u4e2a\u6267\u884c\u4e0a\u4e0b\u6587\uff08\u5982iframe\u6216\u5176\u4ed6\u7a97\u53e3\uff09\u65f6\uff0c\u6bcf\u4e2a\u4e0a\u4e0b\u6587\u90fd\u6709\u81ea\u5df1\u7684\u5168\u5c40\u73af\u5883\uff0c\u56e0\u6b64\u4e5f\u5c31\u6709\u4e86\u4e0d\u540c\u7684\u6784\u9020\u51fd\u6570\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c<strong>instanceof<\/strong> \u53ef\u80fd\u4e0d\u4f1a\u50cf\u9884\u671f\u90a3\u6837\u5de5\u4f5c\uff0c\u56e0\u4e3a\u5bf9\u8c61\u53ef\u80fd\u662f\u5728\u4e0d\u540c\u7684\u4e0a\u4e0b\u6587\u4e2d\u521b\u5efa\u7684\u3002<\/p>\n<\/p>\n<p><h4>\u539f\u578b\u7684\u52a8\u6001\u4fee\u6539<\/h4>\n<\/p>\n<p><p>JavaScript\u5141\u8bb8\u52a8\u6001\u4fee\u6539\u5bf9\u8c61\u7684\u539f\u578b\u3002\u5982\u679c\u5728\u68c0\u6d4b\u4e4b\u540e\u4fee\u6539\u4e86\u6784\u9020\u51fd\u6570\u7684\u539f\u578b\uff0c\u4f7f\u7528 <strong>instanceof<\/strong> \u64cd\u4f5c\u7b26\u53ef\u80fd\u4ea7\u751f\u4e0d\u51c6\u786e\u7684\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u66ff\u4ee3INSTANCEOF\u7684\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u9274\u4e8e <strong>instanceof<\/strong> \u64cd\u4f5c\u7b26\u7684\u4e00\u4e9b\u9650\u5236\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u80fd\u9700\u8981\u5176\u4ed6\u65b9\u6cd5\u6765\u68c0\u6d4b\u5bf9\u8c61\u7c7b\u578b\u3002<\/p>\n<\/p>\n<p><h4>Object.prototype.toString\u65b9\u6cd5<\/h4>\n<\/p>\n<p><p>\u4f7f\u7528 <code>Object.prototype.toString.call(value)<\/code> \u662f\u4e00\u79cd\u66f4\u53ef\u9760\u7684\u7c7b\u578b\u68c0\u6d4b\u65b9\u6cd5\uff0c\u5b83\u53ef\u4ee5\u7cbe\u51c6\u5730\u8fd4\u56de\u5bf9\u8c61\u7684\u7c7b\u578b\uff0c\u5f62\u5f0f\u4e3a <code>[object Type]<\/code>\u3002<\/p>\n<\/p>\n<p><h4>constructor\u5c5e\u6027<\/h4>\n<\/p>\n<p><p>\u5bf9\u8c61\u7684 <code>constructor<\/code> \u5c5e\u6027\u6307\u5411\u521b\u5efa\u8be5\u5bf9\u8c61\u7684\u6784\u9020\u51fd\u6570\u3002\u867d\u7136\u4e0d\u50cf <strong>instanceof<\/strong> \u90a3\u6837\u8003\u8651\u6574\u4e2a\u539f\u578b\u94fe\uff0c\u5374\u53ef\u4ee5\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u786e\u5b9a\u5bf9\u8c61\u7684\u76f4\u63a5\u6784\u9020\u51fd\u6570\u3002<\/p>\n<\/p>\n<p><h4>Duck Typing\uff08\u9e2d\u5b50\u7c7b\u578b\uff09<\/h4>\n<\/p>\n<p><p>\u201c\u770b\u8d77\u6765\u50cf\u9e2d\u5b50\u3001\u8d70\u8def\u50cf\u9e2d\u5b50\uff0c\u90a3\u5b83\u5c31\u662f\u9e2d\u5b50\u201d\u3002\u5728JavaScript\u4e2d\uff0c\u800c\u4e0d\u662f\u68c0\u67e5\u5bf9\u8c61\u662f\u5426\u662f\u7279\u5b9a\u7c7b\u578b\u7684\u5b9e\u4f8b\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u68c0\u67e5\u5bf9\u8c61\u662f\u5426\u6709\u7279\u5b9a\u7684\u65b9\u6cd5\u6216\u5c5e\u6027\uff0c\u6765\u63a8\u65ad\u5176\u7c7b\u578b\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5e94\u7528INSTANCEOF<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c<strong>instanceof<\/strong> \u53ef\u4ee5\u5728\u591a\u6001\u548c\u6a21\u5757\u5316\u4ee3\u7801\u4e2d\u626e\u6f14\u91cd\u8981\u89d2\u8272\uff0c\u4f7f\u5f97\u9879\u76ee\u7ed3\u6784\u66f4\u52a0\u6e05\u6670\u4e14\u6613\u4e8e\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><h4>\u9762\u5411\u5bf9\u8c61\u7684\u7f16\u7a0b<\/h4>\n<\/p>\n<p><p><strong>instanceof<\/strong> \u662f\u7406\u89e3\u548c\u5e94\u7528\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u539f\u5219\u7684\u5173\u952e\u5de5\u5177\u3002\u5b83\u4e3a\u7c7b\u7ee7\u627f\u548c\u591a\u6001\u6027\u63d0\u4f9b\u4e86\u57fa\u7840\uff0c\u4f7f\u5f97\u4ee3\u7801\u66f4\u52a0\u6a21\u5757\u5316\u3002<\/p>\n<\/p>\n<p><h4>\u5904\u7406\u5f02\u5e38<\/h4>\n<\/p>\n<p><p>\u5728\u5904\u7406\u5f02\u5e38\u65f6\uff0c\u80fd\u591f\u68c0\u67e5\u5f02\u5e38\u5bf9\u8c61\u662f\u5426\u5c5e\u4e8e\u67d0\u4e2a\u7279\u5b9a\u7684\u9519\u8bef\u7c7b\u578b\u975e\u5e38\u6709\u7528\u3002\u8fd9\u8ba9\u5f00\u53d1\u8005\u53ef\u4ee5\u9488\u5bf9\u4e0d\u540c\u7684\u9519\u8bef\u7c7b\u578b\u91c7\u53d6\u4e0d\u540c\u7684\u6062\u590d\u7b56\u7565\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u4ec0\u4e48\u662fJavaScript\u4e2d\u7684instanceof\u8fd0\u7b97\u7b26\uff1f<\/strong><\/p>\n<p>JavaScript\u4e2d\u7684instanceof\u8fd0\u7b97\u7b26\u7528\u4e8e\u68c0\u67e5\u5bf9\u8c61\u662f\u5426\u662f\u7279\u5b9a\u7c7b\u578b\u7684\u5b9e\u4f8b\u3002\u5b83\u8fd4\u56de\u4e00\u4e2a\u5e03\u5c14\u503c\uff0c\u6307\u793a\u5bf9\u8c61\u662f\u5426\u5c5e\u4e8e\u6307\u5b9a\u7684\u7c7b\u578b\uff0c\u6216\u8005\u662f\u5426\u662f\u8be5\u7c7b\u578b\u7684\u6d3e\u751f\u7c7b\u7684\u5b9e\u4f8b\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728JavaScript\u4e2d\u4f7f\u7528instanceof\u8fd0\u7b97\u7b26\uff1f<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528instanceof\u8fd0\u7b97\u7b26\u6765\u68c0\u67e5\u4e00\u4e2a\u5bf9\u8c61\u662f\u5426\u5c5e\u4e8e\u67d0\u4e2a\u7c7b\u6216\u5176\u6d3e\u751f\u7c7b\u7684\u5b9e\u4f8b\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u60f3\u68c0\u67e5\u4e00\u4e2a\u5bf9\u8c61\u662f\u5426\u662f\u6570\u7ec4\u7684\u5b9e\u4f8b\uff0c\u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-javascript\">let myArray = [1, 2, 3];\nconsole.log(myArray instanceof Array); \/\/ \u8f93\u51fatrue\n<\/code><\/pre>\n<p>\u6839\u636einstanceof\u8fd0\u7b97\u7b26\u7684\u7ed3\u679c\uff0c\u60a8\u53ef\u4ee5\u6267\u884c\u4e0d\u540c\u7684\u64cd\u4f5c\u6216\u91c7\u53d6\u4e0d\u540c\u7684\u903b\u8f91\u8def\u5f84\u3002<\/p>\n<p><strong>instanceof\u8fd0\u7b97\u7b26\u4e0e\u5176\u4ed6\u7c7b\u578b\u68c0\u67e5\u65b9\u6cd5\u6709\u4f55\u4e0d\u540c\uff1f<\/strong><\/p>\n<p>\u5728JavaScript\u4e2d\uff0c\u9664\u4e86instanceof\u8fd0\u7b97\u7b26\u5916\uff0c\u8fd8\u6709\u5176\u4ed6\u4e00\u4e9b\u7528\u4e8e\u68c0\u67e5\u5bf9\u8c61\u7c7b\u578b\u7684\u65b9\u6cd5\uff0c\u6bd4\u5982typeof\u8fd0\u7b97\u7b26\u548cconstructor\u5c5e\u6027\u3002\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\uff1a<\/p>\n<ul>\n<li>typeof\u8fd0\u7b97\u7b26\uff1atypeof\u8fd0\u7b97\u7b26\u7528\u4e8e\u68c0\u67e5\u4e00\u4e2a\u503c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u6bd4\u5982\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u3001\u5e03\u5c14\u503c\u7b49\u3002\u4f46\u662f\uff0c\u5bf9\u4e8e\u5bf9\u8c61\u7c7b\u578b\uff0ctypeof\u8fd0\u7b97\u7b26\u5c06\u8fd4\u56de&quot;object&quot;\uff0c\u800c\u65e0\u6cd5\u533a\u5206\u4e0d\u540c\u7684\u5bf9\u8c61\u7c7b\u578b\u3002<\/li>\n<li>constructor\u5c5e\u6027\uff1aconstructor\u5c5e\u6027\u662f\u6bcf\u4e2a\u5bf9\u8c61\u90fd\u6709\u7684\u5c5e\u6027\uff0c\u5b83\u6307\u5411\u7528\u4e8e\u521b\u5efa\u5bf9\u8c61\u7684\u6784\u9020\u51fd\u6570\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u6bd4\u8f83\u5bf9\u8c61\u7684constructor\u5c5e\u6027\u6765\u68c0\u67e5\u5b83\u662f\u5426\u5c5e\u4e8e\u67d0\u4e2a\u7c7b\u6216\u5176\u6d3e\u751f\u7c7b\u7684\u5b9e\u4f8b\u3002\u7136\u800c\uff0c\u5982\u679c\u5bf9\u8c61\u662f\u901a\u8fc7\u5b57\u9762\u91cf\u65b9\u5f0f\u521b\u5efa\u7684\uff0c\u5219\u65e0\u6cd5\u8bbf\u95ee\u5176constructor\u5c5e\u6027\u3002<\/li>\n<\/ul>\n<p>\u76f8\u6bd4\u4e4b\u4e0b\uff0cinstanceof\u8fd0\u7b97\u7b26\u63d0\u4f9b\u4e86\u4e00\u79cd\u66f4\u7b80\u6d01\u3001\u65b9\u4fbf\u7684\u65b9\u6cd5\u6765\u68c0\u67e5\u5bf9\u8c61\u662f\u5426\u662f\u7279\u5b9a\u7c7b\u578b\u7684\u5b9e\u4f8b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"JavaScript\u4e2d\u7684instanceof\u64cd\u4f5c\u7b26\u662f\u7528\u4e8e\u6d4b\u8bd5\u6784\u9020\u51fd\u6570\u7684prototype\u5c5e\u6027\u662f\u5426\u51fa\u73b0\u5728\u67d0\u4e2a\u5b9e\u4f8b [&hellip;]","protected":false},"author":3,"featured_media":161595,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/161584"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=161584"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/161584\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/161595"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=161584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=161584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=161584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}