{"id":220808,"date":"2020-11-20T19:15:07","date_gmt":"2020-11-20T11:15:07","guid":{"rendered":"http:\/\/4563.org\/?p=220808"},"modified":"2020-11-20T19:15:07","modified_gmt":"2020-11-20T11:15:07","slug":"%e5%85%b3%e4%ba%8e-instanceof-%e7%9a%84%e7%96%91%e9%97%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=220808","title":{"rendered":"\u5173\u4e8e instanceof \u7684\u7591\u95ee"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5173\u4e8e instanceof \u7684\u7591\u95ee               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rodrick <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p><code>Array instanceof Object<\/code> \u4e3a\u4ec0\u4e48\u662f true \u5462\uff0cMDN \u4e0a\u8bf4<\/p>\n<blockquote>\n<p>instanceof \u8fd0\u7b97\u7b26\u7528\u4e8e\u68c0\u6d4b\u6784\u9020\u51fd\u6570\u7684 prototype \u5c5e\u6027\u662f\u5426\u51fa\u73b0\u5728\u67d0\u4e2a<strong>\u5b9e\u4f8b\u5bf9\u8c61<\/strong>\u7684\u539f\u578b\u94fe\u4e0a\u3002<\/p>\n<\/blockquote>\n<p><code>[] instanceof Object<\/code> \u4e3a <code>true<\/code> \u6211\u80fd\u7406\u89e3<\/p>\n<p>Array \u7b97\u662f\u4e00\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\u4e48\uff1f \u6709\u70b9\u6ca1\u641e\u61c2<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>11<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4447128\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nikandaoleshenme <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e07\u7269\u7686\u5bf9\u8c61\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447129\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : VDimos <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             js \u5565\u90fd\u662f Object\uff0c\u4e0d\u4fe1\u4f60\u770b\u5b83 prototype                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447130\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wunonglin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Array \u672c\u8d28\u4e5f\u662f\u4e2a\u5bf9\u8c61\u3002\u3002\u3002\uff0c\u4f60\u53ef\u4ee5\u901a\u4fd7\u7406\u89e3\u4e3a<\/p>\n<p>&#8220;`<br \/>class Array {<br \/> constructor(){}<br \/>}<br \/>&#8220;`<\/p>\n<p>\u7136\u540e\u6839\u636e mdn \u7684\u89e3\u91ca\u662f\uff1aJavaScript \u7684 Array \u5bf9\u8c61\u662f\u7528\u4e8e\u6784\u9020\u6570\u7ec4\u7684\u5168\u5c40\u5bf9\u8c61\uff0c\u6570\u7ec4\u662f\u7c7b\u4f3c\u4e8e\u5217\u8868\u7684\u9ad8\u9636\u5bf9\u8c61\u3002<\/p>\n<p>\u53c2\u8003\uff1a https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447131\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vision1900 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             JavaScript \u5206 2 \u79cd\u7c7b\u578b\uff1a\u7b80\u5355\u7c7b\u578b\u548c\u5bf9\u8c61\u3002<br \/>\u7b80\u5355\u7c7b\u578b\u5305\u62ec\uff1anumber, string, boolean, null, undefined, \u8fd8\u6709\u6700\u8fd1\u7684 BigInt, Symbol \u3002<br \/>\u5176\u4ed6\u7c7b\u578b\u90fd\u662f\u5bf9\u8c61\u3002Array \u7279\u6b8a\u4e00\u70b9\uff0c\u4ed6\u662f\u4e2a\u6784\u9020\u51fd\u6570\u53c8\u662f\u4e2a\u5bf9\u8c61\uff0c\u800c\u4e14\u662f\u5185\u7f6e\u7684\u3002<br \/>\u8bc1\u660e\u662f\u51fd\u6570: typeof Array === &#8220;function&#8221;<br \/>\u8bc1\u660e\u662f\u5bf9\u8c61\uff1a\u5176\u5b9e\u4e0d\u7528\u8bc1\u660e\uff0c\u51fd\u6570\u5c31\u662f\u5bf9\u8c61\u3002\u975e\u5f97\u8bc1\u660e\u7684\u8bdd\uff0c\u5443\uff0c\u4f60\u81ea\u5df1\u5df2\u7ecf\u8bc1\u660e\u4e86\uff1aArray instanceof Object \u3002<br \/>\u5efa\u8bae\u6df1\u5165\u4e86\u89e3\u4e0b\u539f\u578b\u94fe                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447132\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Reapper <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Object instanceof Function, Array instanceof Function, Function instanceof Object \u5bf9\u8c61\u5206\u4e3a\u666e\u901a\u5bf9\u8c61\u548c\u51fd\u6570\u5bf9\u8c61                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447133\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : rodrick <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @nikandaoleshenme <br \/>@VDimos <br \/>@wunonglin <br \/>@vision1900 <br \/>\u60f3\u8d77\u6765\u4e86\u3002\u3002Object.prototype.toString.call(Array) =&gt; [object Function] <br \/>\u786e\u5b9e\u662f\u5bf9\u8c61\uff0c\u81ea\u5df1\u7ed9\u81ea\u5df1\u6574\u6655\u4e4e\u4e86\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447134\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tabris17 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u56e0\u4e3a Array.__proto__.__proto__ == Object.prototype \u662f true                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447135\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iidear2015 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \/\/ Object \u7684 prototype \u5c5e\u6027\u51fa\u73b0\u5728\u4e86 Array \u7684\u539f\u578b\u94fe\u4e0a<br \/>Object.prototype === Array.__proto__.__proto__ \/\/ true                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447136\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : morethansean <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u81ea\u5df1\u90fd\u56de\u7b54\u4e86\u2026\u2026<br \/>Array.__proto__.__proto__ === Object.prototype<\/p>\n<p>\u53e6\u5916\uff0cMDN \u4e2d\u6587\u8fd9\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\u662f\u4e2d\u6587\u7ffb\u8bd1\u81ea\u5df1\u52a0\u7684\u63cf\u8ff0\uff0c\u5176\u5b9e\u6ca1\u6709\u5b9e\u4f8b\u5bf9\u8c61\u8fd9\u4e2a\u6982\u5ff5\uff0c\u6216\u8005\u8bf4\u5b9e\u4f8b\u5bf9\u8c61\u7684\u5b9a\u4e49\u5c31\u662f instanceof \u7684\u5b9a\u4e49\uff0c\u90a3\u5c31\u662f\u8981\u4e48 Symbol.hasInstance \u8fd4\u56de true \u4e86\u8981\u4e48\u5c31\u662f constructor \u7684 prototype \u51fa\u73b0\u5728\u4e86 object \u7684\u539f\u578b\u94fe\u4e0a\uff1a<br \/>object instance of constructor                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447137\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : auroraccc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Array \u662f\u4e00\u4e2a\u51fd\u6570\u54c7\uff0c\u51fd\u6570\u672c\u8eab\u5c31\u662f\u4e00\u4e2a\u5bf9\u8c61                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4447138\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : rodrick <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @morethansean \u5bf9\uff0c\u4e3b\u8981\u662f\u770b\u5230 MDN \u7684\u7ffb\u8bd1\u8bf4\u201c\u5b9e\u4f8b\u5bf9\u8c61\u201d\uff0c\u4e2a\u4eba\u89c9\u5f97\u5bf9\u8c61\u548c\u5b9e\u4f8b\u4e0d\u662f\u4e00\u4e2a\u6982\u5ff5\uff0c\u4e00\u4e0b\u6ca1\u53cd\u5e94\u8fc7\u6765\uff0c\u770b\u4e86\u4e0b\u82f1\u6587\u7684\u539f\u6587\u5c31\u662f object                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e instanceof \u7684\u7591\u95ee&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/220808"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=220808"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/220808\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=220808"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=220808"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=220808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}