-
Notifications
You must be signed in to change notification settings - Fork 1
/
3a5a032b.20b415fa.js
1 lines (1 loc) · 34.7 KB
/
3a5a032b.20b415fa.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[27],{159:function(e,t,n){"use strict";n.d(t,"a",(function(){return O})),n.d(t,"b",(function(){return m}));var a=n(0),b=n.n(a);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t){if(null==e)return{};var n,a,b=function(e,t){if(null==e)return{};var n,a,b={},l=Object.keys(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||(b[n]=e[n]);return b}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(b[n]=e[n])}return b}var p=b.a.createContext({}),j=function(e){var t=b.a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):r(r({},t),e)),n},O=function(e){var t=j(e.components);return b.a.createElement(p.Provider,{value:t},e.children)},o={inlineCode:"code",wrapper:function(e){var t=e.children;return b.a.createElement(b.a.Fragment,{},t)}},d=b.a.forwardRef((function(e,t){var n=e.components,a=e.mdxType,l=e.originalType,i=e.parentName,p=c(e,["components","mdxType","originalType","parentName"]),O=j(n),d=a,m=O["".concat(i,".").concat(d)]||O[d]||o[d]||l;return n?b.a.createElement(m,r(r({ref:t},p),{},{components:n})):b.a.createElement(m,r({ref:t},p))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var l=n.length,i=new Array(l);i[0]=d;var r={};for(var c in t)hasOwnProperty.call(t,c)&&(r[c]=t[c]);r.originalType=e,r.mdxType="string"==typeof e?e:a,i[1]=r;for(var p=2;p<l;p++)i[p]=n[p];return b.a.createElement.apply(null,i)}return b.a.createElement.apply(null,n)}d.displayName="MDXCreateElement"},281:function(e,t,n){"use strict";n.r(t),t.default=n.p+"assets/images/type-conversion-69021f78d70c04295454b3e2868f81e6.svg"},96:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return i})),n.d(t,"metadata",(function(){return r})),n.d(t,"rightToc",(function(){return c})),n.d(t,"default",(function(){return j}));var a=n(3),b=n(7),l=(n(0),n(159)),i={id:"types-and-conversion",title:"\u6570\u636e\u7c7b\u578b\u4e0e\u7c7b\u578b\u8f6c\u6362"},r={unversionedId:"interview/js/types-and-conversion",id:"interview/js/types-and-conversion",isDocsHomePage:!1,title:"\u6570\u636e\u7c7b\u578b\u4e0e\u7c7b\u578b\u8f6c\u6362",description:"\u6570\u636e\u7c7b\u578b",source:"@site/docs/interview/js/types-and-conversion.md",slug:"/interview/js/types-and-conversion",permalink:"/docs/interview/js/types-and-conversion",editUrl:"https://github.com/kenve/kenve.github.io/edit/docusaurus/docs/interview/js/types-and-conversion.md",version:"current",sidebar:"interviewSideBar",previous:{title:"null \u548c undefined",permalink:"/docs/interview/js/null-and-undefined"},next:{title:"\u6570\u7ec4 Array",permalink:"/docs/interview/js/js-array"}},c=[{value:"\u6570\u636e\u7c7b\u578b",id:"\u6570\u636e\u7c7b\u578b",children:[]},{value:"\u539f\u59cb\u503c",id:"\u539f\u59cb\u503c",children:[]},{value:"Object",id:"object",children:[]},{value:"\u7c7b\u578b\u8f6c\u6362",id:"\u7c7b\u578b\u8f6c\u6362",children:[{value:"\u663e\u793a\u7c7b\u578b\u8f6c\u6362",id:"\u663e\u793a\u7c7b\u578b\u8f6c\u6362",children:[]},{value:"Falsy",id:"falsy",children:[]},{value:"\u903b\u8f91\u8fd0\u7b97\u7b26",id:"\u903b\u8f91\u8fd0\u7b97\u7b26",children:[]},{value:"\u7b97\u672f\u8fd0\u7b97\u7b26",id:"\u7b97\u672f\u8fd0\u7b97\u7b26",children:[]},{value:"\u6bd4\u8f83\u8fd0\u7b97\u7b26",id:"\u6bd4\u8f83\u8fd0\u7b97\u7b26",children:[]}]}],p={rightToc:c};function j(e){var t=e.components,i=Object(b.a)(e,["components"]);return Object(l.b)("wrapper",Object(a.a)({},p,i,{components:t,mdxType:"MDXLayout"}),Object(l.b)("h2",{id:"\u6570\u636e\u7c7b\u578b"},"\u6570\u636e\u7c7b\u578b"),Object(l.b)("p",null,"\u6700\u65b0\u7684 ECMAScript \u6807\u51c6\u5b9a\u4e49\u4e86 9 \u79cd\u7c7b\u578b\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"6 \u79cd\u539f\u59cb\u6570\u636e\u7c7b\u578b\uff0c\u53ef\u4ee5\u4f7f\u7528 ",Object(l.b)("inlineCode",{parentName:"li"},"typeof")," \u8fd0\u7b97\u7b26\u53f7\u68c0\u6d4b\uff1a",Object(l.b)("ul",{parentName:"li"},Object(l.b)("li",{parentName:"ul"},"undefined : ",Object(l.b)("inlineCode",{parentName:"li"},'typeof instance === "undefined"')),Object(l.b)("li",{parentName:"ul"},"Boolean : ",Object(l.b)("inlineCode",{parentName:"li"},'typeof instance === "boolean"')),Object(l.b)("li",{parentName:"ul"},"Number : ",Object(l.b)("inlineCode",{parentName:"li"},'typeof instance === "number"')),Object(l.b)("li",{parentName:"ul"},"String : ",Object(l.b)("inlineCode",{parentName:"li"},'typeof instance === "string"')),Object(l.b)("li",{parentName:"ul"},"BigInt : ",Object(l.b)("inlineCode",{parentName:"li"},'typeof instance === "bigint"')),Object(l.b)("li",{parentName:"ul"},"Symbol : ",Object(l.b)("inlineCode",{parentName:"li"},'typeof instance === "symbol"')))),Object(l.b)("li",{parentName:"ul"},"null : ",Object(l.b)("inlineCode",{parentName:"li"},'typeof instance=== "object"')," \u7279\u6b8a\u7684\u539f\u59cb\u7c7b\u578b\uff0c"),Object(l.b)("li",{parentName:"ul"},"Object : ",Object(l.b)("inlineCode",{parentName:"li"},'typeof instance === "object"')," \u5bf9\u8c61\uff0c\u5f15\u7528\u7c7b\u578b\u3002"),Object(l.b)("li",{parentName:"ul"},"Function : ",Object(l.b)("inlineCode",{parentName:"li"},'typeof instance === "function"')," \u51fd\u6570\uff0c\u5f15\u7528\u7c7b\u578b\u3002")),Object(l.b)("blockquote",null,Object(l.b)("p",{parentName:"blockquote"},"typeof \u548c instanceof \u7684\u533a\u522b")),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"typeof")," \u662f\u4e00\u5143\u8fd0\u7b97\u7b26\uff0c\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\u7c7b\u578b\u3002\u4e00\u822c\u7528\u6765\u5224\u65ad\u4e00\u4e2a\u53d8\u91cf\u662f\u5426\u4e3a\u7a7a\u6216\u8005\u503c\u662f\u4ec0\u4e48\u7c7b\u578b\u3002\u9664\u4e86 null \u7c7b\u578b\u4ee5\u53ca Object \u7c7b\u578b\u4e0d\u80fd\u51c6\u786e\u5224\u65ad\u5916\uff0c\u5176\u4ed6\u6570\u636e\u7c7b\u578b\u90fd\u53ef\u80fd\u8fd4\u56de\u6b63\u786e\u7684\u7c7b\u578b\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'typeof undefined; // "undefined"\ntypeof \'10\'; // "string"\ntypeof 10; // "number"\ntypeof false; // "boolean"\ntypeof Symbol(); // "symbol"\ntypeof Function; // "function"\ntypeof null; // "object"\ntypeof []; // "object"\ntypeof {}; // "object"\n')),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"instanceof")," \u6765\u8fdb\u884c\u5224\u65ad\u67d0\u4e2a\u5bf9\u8c61\u662f\u4e0d\u662f\u53e6\u4e00\u4e2a\u5bf9\u8c61\u7684\u5b9e\u4f8b\u3002\u8fd4\u56de\u503c\u7684\u662f\u4e00\u4e2a\u5e03\u5c14\u7c7b\u578b\u3002",Object(l.b)("inlineCode",{parentName:"p"},"instanceof")," \u8fd0\u7b97\u7b26\u7528\u6765\u6d4b\u8bd5\u4e00\u4e2a\u5bf9\u8c61\u5728\u5176\u539f\u578b\u94fe\u4e2d\u662f\u5426\u5b58\u5728\u4e00\u4e2a\u6784\u9020\u51fd\u6570\u7684 ",Object(l.b)("inlineCode",{parentName:"p"},"prototype")," \u5c5e\u6027\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"const a = [];\nconsole.log(a instanceof Array); // true\n")),Object(l.b)("p",null,"\u5047\u8bbe\u73b0\u5728\u6709 ",Object(l.b)("inlineCode",{parentName:"p"},"a instanceof b")," \u4e00\u6761\u8bed\u53e5\uff0c\u5219\u5176 ",Object(l.b)("inlineCode",{parentName:"p"},"instanceof")," \u5185\u90e8\u5b9e\u9645\u505a\u4e86\u5982\u4e0b\u5224\u65ad\uff1a"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"while (a.__proto__ !== null) {\n if (a.__proto__ === b.prototype) {\n return true;\n }\n a.__proto__ = a.__proto__.proto__;\n}\nif (a.__proto__ == null) {\n return false;\n}\n")),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"a")," \u4f1a\u4e00\u76f4\u6cbf\u7740\u9690\u5f0f\u539f\u578b\u94fe ",Object(l.b)("inlineCode",{parentName:"p"},"__proto__")," \u5411\u4e0a\u67e5\u627e\u76f4\u5230 ",Object(l.b)("inlineCode",{parentName:"p"},"a.__proto__.__proto__ ...... === b.prototype")," \u4e3a\u6b62\uff0c\u5982\u679c\u627e\u5230\u5219\u8fd4\u56de ",Object(l.b)("inlineCode",{parentName:"p"},"true"),"\uff0c\u4e5f\u5c31\u662f ",Object(l.b)("inlineCode",{parentName:"p"},"a")," \u4e3a ",Object(l.b)("inlineCode",{parentName:"p"},"b")," \u7684\u4e00\u4e2a\u5b9e\u4f8b\u3002\u5426\u5219\u8fd4\u56de ",Object(l.b)("inlineCode",{parentName:"p"},"false"),"\uff0c",Object(l.b)("inlineCode",{parentName:"p"},"a")," \u4e0d\u662f ",Object(l.b)("inlineCode",{parentName:"p"},"b")," \u7684\u5b9e\u4f8b\u3002"),Object(l.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"tip")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},Object(l.b)("inlineCode",{parentName:"p"},"Object.prototype.toString")," \u4e5f\u53ef\u4ee5\u5224\u65ad\u7c7b\u578b\u3002",Object(l.b)("inlineCode",{parentName:"p"},"Object.prototype.toString.call(a)")," \u8f93\u51fa ",Object(l.b)("inlineCode",{parentName:"p"},'"[object Array]"'),"\u3002"))),Object(l.b)("h2",{id:"\u539f\u59cb\u503c"},"\u539f\u59cb\u503c"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"Boonle \u7c7b\u578b\uff0c\u5305\u542b\u4e24\u4e2a ",Object(l.b)("inlineCode",{parentName:"li"},"true")," \u548c ",Object(l.b)("inlineCode",{parentName:"li"},"false"),"\u3002"),Object(l.b)("li",{parentName:"ul"},"Null \u7c7b\u578b\uff0c\u5305\u542b\u4e00\u4e2a\u503c ",Object(l.b)("inlineCode",{parentName:"li"},"null"),"\u3002"),Object(l.b)("li",{parentName:"ul"},"Undefined \u7c7b\u578b\uff0c\u672a\u5b9a\u4e49\uff0c\u5305\u542b\u4e00\u4e2a\u503c ",Object(l.b)("inlineCode",{parentName:"li"},"undefined"),"\u3002"),Object(l.b)("li",{parentName:"ul"},"Number \u7c7b\u578b\uff0c\u5305\u542b\u4e24\u79cd\u6570\u5b57\u7c7b\u578b Number \u548c Bigint\u3002",Object(l.b)("ul",{parentName:"li"},Object(l.b)("li",{parentName:"ul"},"Number \u7c7b\u578b\u662f\u53cc\u7cbe\u5ea6 64 \u4f4d\u4e8c\u8fdb\u5236\u683c\u5f0f IEEE 754 \u503c\uff08-(2",Object(l.b)("sup",null,"53"),"-1)\u548c 2",Object(l.b)("sup",null,"53"),"-1 \u4e4b\u95f4\u7684\u6570\u5b57\uff09\u3002\u9664\u4e86\u8868\u793a\u6d6e\u70b9\u6570\uff0c\u6570\u5b57\u7c7b\u578b\u8fd8\u5177\u6709\u4e09\u4e2a\u503c\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"+Infinity"),"\uff0c",Object(l.b)("inlineCode",{parentName:"li"},"-Infinity")," \u548c ",Object(l.b)("inlineCode",{parentName:"li"},"NaN"),"\u3002"))),Object(l.b)("li",{parentName:"ul"},"Bigint \u7c7b\u578b\uff0c\u53ef\u4ee5\u8868\u793a\u4efb\u610f\u7cbe\u5ea6\u7684\u6574\u6570\u3002 \u901a\u8fc7\u5c06 n \u9644\u52a0\u5230\u6574\u6570\u7684\u672b\u5c3e\u6216\u8c03\u7528\u6784\u9020\u51fd\u6570\u6765\u521b\u5efa BigInt\u3002 \u53ef\u4ee5\u5b89\u5168\u5730\u5b58\u50a8\u548c\u64cd\u4f5c\u5927\u6574\u6570\uff0c\u751a\u81f3\u53ef\u4ee5\u8d85\u51fa Numbers \u7684\u5b89\u5168\u6574\u6570\u9650\u5236\u3002"),Object(l.b)("li",{parentName:"ul"},"String \u7c7b\u578b\uff0c\u7528\u4e8e\u8868\u793a\u6587\u672c\u6570\u636e\u3002 \u5b83\u662f\u4e00\u7ec4 16 \u4f4d\u65e0\u7b26\u53f7\u6574\u6570\u503c\u7684\u201c\u5143\u7d20\u201d\u3002"),Object(l.b)("li",{parentName:"ul"},"Symbol \u7c7b\u578b\uff0c\u662f\u552f\u4e00\u4e14\u4e0d\u53ef\u53d8\u7684\u539f\u59cb\u503c\uff0c\u53ef\u4ee5\u7528\u4f5c Object \u5c5e\u6027\u7684\u952e\u3002")),Object(l.b)("h2",{id:"object"},"Object"),Object(l.b)("p",null,"\u5728\u8ba1\u7b97\u673a\u79d1\u5b66\u4e2d\uff0c\u5bf9\u8c61\u662f\u5185\u5b58\u4e2d\u7684\u503c\uff0c\u53ef\u7531\u6807\u8bc6\u7b26\uff08\u6807\u8bc6\u7b26\u662f\u4e00\u4e2a\u5b57\u7b26\u5728\u4ee3\u7801\u6807\u8bc6\u7684\u5e8f\u5217\u53d8\u91cf\uff0c\u51fd\u6570\uff0c\u6216\u5c5e\u6027\u3002\uff09\u5f15\u7528\u3002"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"Object"),Object(l.b)("li",{parentName:"ul"},"Array"),Object(l.b)("li",{parentName:"ul"},"Date"),Object(l.b)("li",{parentName:"ul"},"RegExp"),Object(l.b)("li",{parentName:"ul"},"Function")),Object(l.b)("h2",{id:"\u7c7b\u578b\u8f6c\u6362"},"\u7c7b\u578b\u8f6c\u6362"),Object(l.b)("p",null,"\u7c7b\u578b\u8f6c\u6362\u5206\u4e3a",Object(l.b)("strong",{parentName:"p"},"\u663e\u5f0f\u7c7b\u578b\u8f6c\u6362"),"\u548c",Object(l.b)("strong",{parentName:"p"},"\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362"),"\u3002\u6bcf\u79cd\u8f6c\u6362\u53c8\u5206\u4e3a",Object(l.b)("strong",{parentName:"p"},"\u539f\u59cb\u7c7b\u578b\u8f6c\u6362"),"\u548c",Object(l.b)("strong",{parentName:"p"},"\u5bf9\u8c61\u7c7b\u578b\u8f6c\u6362"),"\u3002"),Object(l.b)("h3",{id:"\u663e\u793a\u7c7b\u578b\u8f6c\u6362"},"\u663e\u793a\u7c7b\u578b\u8f6c\u6362"),Object(l.b)("p",null,"\u5f3a\u5236\u8f6c\u6362\u4e3b\u8981\u6307\u4f7f\u7528 Number()\u3001String()\u548c Boolean()\u4e09\u4e2a\u51fd\u6570\uff0c\u624b\u52a8\u5c06\u5404\u79cd\u7c7b\u578b\u7684\u503c\uff0c\u5206\u522b\u8f6c\u6362\u6210\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u6216\u8005\u5e03\u5c14\u503c\u3002"),Object(l.b)("p",null,"\u5bf9\u4e8e\u539f\u59cb\u7c7b\u578b\u6765\u8bf4\uff0c\u8f6c\u5b57\u7b26\u4e32\u7c7b\u578b\u4f1a\u9ed8\u8ba4\u8c03\u7528 ",Object(l.b)("inlineCode",{parentName:"p"},"toString()")," \u51fd\u6570\uff0c\u9664 ",Object(l.b)("inlineCode",{parentName:"p"},"null")," \u548c ",Object(l.b)("inlineCode",{parentName:"p"},"undefined")," \u5916\u3002"),Object(l.b)("table",null,Object(l.b)("thead",{parentName:"table"},Object(l.b)("tr",{parentName:"thead"},Object(l.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"\u6570\u636e\u7c7b\u578b"),Object(l.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"String \u7c7b\u578b"))),Object(l.b)("tbody",{parentName:"table"},Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u6570\u5b57"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u8f6c\u5316\u4e3a\u6570\u5b57\u5bf9\u5e94\u7684\u5b57\u7b26\u4e32")),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u5e03\u5c14\u7c7b\u578b"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u8f6c\u5316\u4e3a\u5b57\u7b26\u4e32 ",Object(l.b)("inlineCode",{parentName:"td"},'"true"'))),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"null"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u8f6c\u5316\u4e3a\u5b57\u7b26\u4e32 ",Object(l.b)("inlineCode",{parentName:"td"},'"null"'))),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"undefined"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u8f6c\u5316\u4e3a\u5b57\u7b26\u4e32 ",Object(l.b)("inlineCode",{parentName:"td"},'"undefined\u201d'))),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"Object"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u8f6c\u5316\u4e3a ",Object(l.b)("inlineCode",{parentName:"td"},'"[object Object]"'))))),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),'String(123); // "123"\nString(true); // "true"\nString(null); // "null"\nString(undefined); // "undefined"\nString([1, 2, 3]); // "1,2,3"\nString({}); // "[object Object]"\n')),Object(l.b)("p",null,"\u5176\u4ed6\u7c7b\u578b\u8f6c\u6570\u5b57\u7c7b\u578b\uff1a"),Object(l.b)("table",null,Object(l.b)("thead",{parentName:"table"},Object(l.b)("tr",{parentName:"thead"},Object(l.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"\u6570\u636e\u7c7b\u578b"),Object(l.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"\u6570\u5b57\u7c7b\u578b"))),Object(l.b)("tbody",{parentName:"table"},Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u5b57\u7b26\u4e32"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"1. \u6570\u5b57\u8f6c\u5316\u4e3a\u5bf9\u5e94\u7684\u6570\u5b57\uff1b 2. \u5176\u4ed6\u8f6c\u5316\u4e3a ",Object(l.b)("inlineCode",{parentName:"td"},"NaN"))),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u5e03\u5c14\u7c7b\u578b"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"1. ",Object(l.b)("inlineCode",{parentName:"td"},"true")," \u8f6c\u5316\u4e3a ",Object(l.b)("inlineCode",{parentName:"td"},"1"),"\uff1b 2. ",Object(l.b)("inlineCode",{parentName:"td"},"false")," \u8f6c\u5316\u4e3a ",Object(l.b)("inlineCode",{parentName:"td"},"0"))),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"null"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"0"))),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"undefined"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"NaN"))),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u6570\u7ec4"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"1. \u6570\u7ec4\u4e3a\u7a7a\u8f6c\u5316\u4e3a ",Object(l.b)("inlineCode",{parentName:"td"},"0"),"\uff1b2. \u6570\u7ec4\u53ea\u6709\u4e00\u4e2a\u5143\u7d20\u8f6c\u5316\u4e3a\u5bf9\u5e94\u5143\u7d20\uff1b3. \u5176\u4ed6\u8f6c\u5316\u4e3a ",Object(l.b)("inlineCode",{parentName:"td"},"NaN"))),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u7a7a\u5b57\u7b26\u4e32"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"0"))))),Object(l.b)("h3",{id:"falsy"},"Falsy"),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"falsy(falsey)")," \u503c (\u865a\u503c) \u662f\u5728 Boolean \u4e0a\u4e0b\u6587\u4e2d\u8ba4\u5b9a\u4e3a false \u7684\u503c\u3002"),Object(l.b)("p",null,"JavaScript \u5728\u9700\u8981\u7528\u5230\u5e03\u5c14\u7c7b\u578b\u503c\u7684\u4e0a\u4e0b\u6587\u4e2d\u4f7f\u7528\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362(Type Conversion )\u5c06\u503c\u8f6c\u6362\u4e3a\u5e03\u5c14\u503c\uff0c\u4f8b\u5982\u6761\u4ef6\u8bed\u53e5\u548c\u5faa\u73af\u8bed\u53e5\u3002"),Object(l.b)("p",null,"\u5728 JavaScript \u4e2d\u53ea\u6709 7 \u4e2a falsy \u503c\uff0c\u8fd9\u610f\u5473\u7740\u5f53 JavaScript \u671f\u671b\u4e00\u4e2a\u5e03\u5c14\u503c\uff0c\u5e76\u88ab\u7ed9\u4e0e\u4e0b\u9762\u503c\u4e2d\u7684\u4e00\u4e2a\u65f6\u3002"),Object(l.b)("table",null,Object(l.b)("thead",{parentName:"table"},Object(l.b)("tr",{parentName:"thead"},Object(l.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"\u503c"),Object(l.b)("th",Object(a.a)({parentName:"tr"},{align:null}),"\u8bf4\u660e"))),Object(l.b)("tbody",{parentName:"table"},Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"false")),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"false \u5173\u952e\u5b57")),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"0")),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u6570\u503c zero")),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"0n")),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u5f53 BigInt \u4f5c\u4e3a\u5e03\u5c14\u503c\u4f7f\u7528\u65f6, \u9075\u4ece\u5176\u4f5c\u4e3a\u6570\u503c\u7684\u89c4\u5219. ",Object(l.b)("inlineCode",{parentName:"td"},"0n")," \u662f falsy \u503c")),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},'""'),", ",Object(l.b)("inlineCode",{parentName:"td"},"''"),", ","`","`"),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),"\u8fd9\u662f\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32 (\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u4e3a\u96f6)\u3002 JavaScript \u4e2d\u7684\u5b57\u7b26\u4e32\u53ef\u7528\u53cc\u5f15\u53f7 ",Object(l.b)("inlineCode",{parentName:"td"},'""'),"\uff0c\u5355\u5f15\u53f7 ",Object(l.b)("inlineCode",{parentName:"td"},"''"),"\uff0c\u6216 \u6a21\u677f\u5b57\u9762\u91cf ","`","`"," \u5b9a\u4e49")),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"null")),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"null")," - \u7f3a\u5c11\u503c")),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"undefined")),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"undefined")," - \u539f\u59cb\u503c")),Object(l.b)("tr",{parentName:"tbody"},Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"NaN")),Object(l.b)("td",Object(a.a)({parentName:"tr"},{align:null}),Object(l.b)("inlineCode",{parentName:"td"},"NaN")," - \u975e\u6570\u503c")))),Object(l.b)("p",null,"JavaScript \u4e2d ",Object(l.b)("em",{parentName:"p"},"falsy")," \u503c\u7684\u4f8b\u5b50 (\u5728\u5e03\u5c14\u503c\u4e0a\u4e0b\u6587\u4e2d\u88ab\u8f6c\u6362\u4e3a false\uff0c\u4ece\u800c\u7ed5\u8fc7\u4e86 ",Object(l.b)("inlineCode",{parentName:"p"},"if")," \u4ee3\u7801\u5757):"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"if (false)\nif (null)\nif (undefined)\nif (0)\nif (0n)\nif (NaN)\nif ('')\nif (\"\")\nif (``)\nif (document.all)\n")),Object(l.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"})))),"caution")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},Object(l.b)("inlineCode",{parentName:"p"},"document.all")," \u5728\u8fc7\u53bb\u88ab\u7528\u4e8e\u6d4f\u89c8\u5668\u68c0\u6d4b\uff0c\u662f HTML \u89c4\u8303\u5728\u6b64\u5b9a\u4e49\u4e86\u6545\u610f\u4e0e ECMAScript \u6807\u51c6\u76f8\u8fdd\u80cc\u7684\uff08",Object(l.b)("inlineCode",{parentName:"p"},"document.all")," \u867d\u7136\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u4f46\u5176\u8f6c\u6362\u4e3a boolean \u7c7b\u578b\u662f false\uff09"))),Object(l.b)("h3",{id:"\u903b\u8f91\u8fd0\u7b97\u7b26"},"\u903b\u8f91\u8fd0\u7b97\u7b26"),Object(l.b)("h4",{id:"\u8d4b\u503c\u64cd\u4f5c"},"\u8d4b\u503c\u64cd\u4f5c"),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u4e14\u8fd0\u7b97\u7b26"),"\uff08",Object(l.b)("inlineCode",{parentName:"p"},"&&"),"\uff09\u89c4\u5219\u662f\uff1a\u5982\u679c\u7b2c\u4e00\u4e2a\u503c\u7684\u5e03\u5c14\u503c\u4e3a ",Object(l.b)("inlineCode",{parentName:"p"},"true"),"\uff0c\u5219\u8fd4\u56de\u7b2c\u4e8c\u4e2a\u7684\u503c\uff08\u6ce8\u610f\u662f\u503c\uff0c\u4e0d\u662f\u5e03\u5c14\u503c\uff09\uff1b\u5982\u679c\u7b2c\u4e00\u4e2a\u503c\u7684\u5e03\u5c14\u503c\u4e3a ",Object(l.b)("inlineCode",{parentName:"p"},"false"),"\uff0c\u5219\u76f4\u63a5\u8fd4\u56de\u7b2c\u4e00\u4e2a\u7684\u503c\uff0c\u4e14\u4e0d\u518d\u5bf9\u7b2c\u4e8c\u4e2a\u6c42\u503c\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"let pet = '' && 'dog'; // \u21aa \"\"\nlet pet1 = 'cat' && 'dog'; // \u21aa \"dog\"\n")),Object(l.b)("p",null,Object(l.b)("strong",{parentName:"p"},"\u6216\u8fd0\u7b97\u7b26"),"\uff08",Object(l.b)("inlineCode",{parentName:"p"},"||"),"\uff09\u89c4\u5219\u662f\uff1a\u5982\u679c\u7b2c\u4e00\u4e2a\u503c\u7684\u5e03\u5c14\u503c\u4e3a ",Object(l.b)("inlineCode",{parentName:"p"},"true"),"\uff0c\u5219\u8fd4\u56de\u7b2c\u4e00\u4e2a\u7684\u503c\uff0c\u4e14\u4e0d\u518d\u5bf9\u7b2c\u4e8c\u4e2a\u6c42\u503c\uff1b\u5982\u679c\u7b2c\u4e00\u4e2a\u7684\u5e03\u5c14\u503c\u4e3a ",Object(l.b)("inlineCode",{parentName:"p"},"false"),"\uff0c\u5219\u8fd4\u56de\u7b2c\u4e8c\u4e2a\u7684\u503c\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"let pet = '' || 'dog'; // \u21aa \"dog\"\nlet pet1 = 'cat' || 'dog'; // \u21aa \"cat\"\n")),Object(l.b)("h4",{id:"\u6761\u4ef6\u5224\u65ad"},"\u6761\u4ef6\u5224\u65ad"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},"!")," \uff1a\u53d6\u53cd\u3002\n",Object(l.b)("inlineCode",{parentName:"p"},"&&")," \uff1a\u6240\u6709\u6761\u4ef6\u4e3a\u771f\uff0c\u6574\u4f53\u624d\u4e3a\u771f\u3002\n",Object(l.b)("inlineCode",{parentName:"p"},"||")," \uff1a\u53ea\u6709\u4e00\u4e2a\u6761\u4ef6\u4e3a\u771f\uff0c\u6574\u4f53\u5c31\u4e3a\u771f\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"!true; // false\ntrue && true; // true\ntrue && false; // false\ntrue || true; // true\ntrue || false; // true\n")),Object(l.b)("h3",{id:"\u7b97\u672f\u8fd0\u7b97\u7b26"},"\u7b97\u672f\u8fd0\u7b97\u7b26"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u52a0\u6cd5\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"x + y")),Object(l.b)("li",{parentName:"ul"},"\u51cf\u6cd5\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"x - y")),Object(l.b)("li",{parentName:"ul"},"\u4e58\u6cd5\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"x * y")),Object(l.b)("li",{parentName:"ul"},"\u9664\u6cd5\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"x / y")),Object(l.b)("li",{parentName:"ul"},"\u6307\u6570\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"x ** y")),Object(l.b)("li",{parentName:"ul"},"\u4f59\u6570\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"x % y")),Object(l.b)("li",{parentName:"ul"},"\u81ea\u589e\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"++x")," \u6216\u8005 ",Object(l.b)("inlineCode",{parentName:"li"},"x++")),Object(l.b)("li",{parentName:"ul"},"\u81ea\u51cf\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"--x")," \u6216\u8005 ",Object(l.b)("inlineCode",{parentName:"li"},"x--")),Object(l.b)("li",{parentName:"ul"},"\u6570\u503c\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"+x")),Object(l.b)("li",{parentName:"ul"},"\u8d1f\u6570\u503c\u8fd0\u7b97\u7b26\uff1a",Object(l.b)("inlineCode",{parentName:"li"},"-x"))),Object(l.b)("h4",{id:"\u52a0\u6cd5\u8fd0\u7b97\u7b26"},"\u52a0\u6cd5\u8fd0\u7b97\u7b26"),Object(l.b)("blockquote",null,Object(l.b)("p",{parentName:"blockquote"},"\u8fd0\u7b97\u6570\u7684\u4e0d\u540c\uff0c\u5bfc\u81f4\u4e86\u4e0d\u540c\u7684\u8bed\u6cd5\u884c\u4e3a\uff0c\u8fd9\u79cd\u73b0\u8c61\u79f0\u4e3a\u201c\u91cd\u8f7d\u201d\u3002")),Object(l.b)("p",null,"\u5982\u679c\u53cc\u65b9\u90fd\u4e0d\u662f\u5b57\u7b26\u4e32\uff0c\u5219\u5c06\u8f6c\u5316\u4e3a",Object(l.b)("strong",{parentName:"p"},"\u6570\u5b57"),"\u6216",Object(l.b)("strong",{parentName:"p"},"\u5b57\u7b26\u4e32"),"\u3002"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"Boolean + Boolean \u4f1a\u8f6c\u5316\u4e3a\u6570\u5b57\u76f8\u52a0\u3002"),Object(l.b)("li",{parentName:"ul"},"Boolean + Number \u5e03\u5c14\u7c7b\u578b\u8f6c\u5316\u4e3a\u6570\u5b57\u76f8\u52a0\u3002"),Object(l.b)("li",{parentName:"ul"},"Object + Number \u5bf9\u8c61\u7c7b\u578b\u8c03\u7528 ",Object(l.b)("inlineCode",{parentName:"li"},"valueOf"),"\uff0c\u5982\u679c\u4e0d\u662f String\u3001Boolean \u6216\u8005 Number \u7c7b\u578b\uff0c\u5219\u7ee7\u7eed\u8c03\u7528 ",Object(l.b)("inlineCode",{parentName:"li"},"toString()")," \u8f6c\u5316\u4e3a\u5b57\u7b26\u4e32\u3002"),Object(l.b)("li",{parentName:"ul"},"String + Any \u5982\u679c\u4e00\u4e2a\u503c\u662f\u5b57\u7b26\u4e32\uff0c\u53e6\u4e00\u4e2a\u8fd0\u7b97\u5b50\u662f\u975e\u5b57\u7b26\u4e32\uff0c\u8fd9\u65f6\u975e\u5b57\u7b26\u4e32\u4f1a\u8f6c\u6210\u5b57\u7b26\u4e32\uff0c\u518d\u8fde\u63a5\u5728\u4e00\u8d77\u3002")),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"true + true; // 2\n1 + true; // 2\n[1] + 3; // '13'\n\n'3' + 4 + 5; // \"345\"\n3 + 4 + '5'; // \"75\"\n")),Object(l.b)("p",null,"\u590d\u5236\u4ee3\u7801\u5b57\u7b26\u4e32\u548c\u5b57\u7b26\u4e32\u4ee5\u53ca\u5b57\u7b26\u4e32\u548c\u975e\u5b57\u7b26\u4e32\u76f8\u52a0\u90fd\u4f1a\u8fdb\u884c\u8fde\u63a5\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"1 + 'b'; // \u20181b\u2019\nfalse + 'b'; // \u2018falseb\u2019\n")),Object(l.b)("p",null,"\u9664\u4e86\u52a0\u6cd5\u8fd0\u7b97\u7b26\uff0c\u5176\u4ed6\u7b97\u672f\u8fd0\u7b97\u7b26\uff08\u6bd4\u5982\u51cf\u6cd5\u3001\u9664\u6cd5\u548c\u4e58\u6cd5\uff09\u90fd\u4e0d\u4f1a\u53d1\u751f\u91cd\u8f7d\u3002\u5b83\u4eec\u7684\u89c4\u5219\u662f\uff1a\u6240\u6709\u8fd0\u7b97\u5b50\u4e00\u5f8b\u8f6c\u4e3a\u6570\u503c\uff0c\u518d\u8fdb\u884c\u76f8\u5e94\u7684\u6570\u5b66\u8fd0\u7b97\u3002"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-js"}),"1 - '2'; // -1\n1 * '2'; // 2\n1 / '2'; // 0.5\n")),Object(l.b)("h3",{id:"\u6bd4\u8f83\u8fd0\u7b97\u7b26"},"\u6bd4\u8f83\u8fd0\u7b97\u7b26"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},">")," \u5927\u4e8e\u8fd0\u7b97\u7b26"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"<")," \u5c0f\u4e8e\u8fd0\u7b97\u7b26"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"<=")," \u5c0f\u4e8e\u6216\u7b49\u4e8e\u8fd0\u7b97\u7b26"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},">=")," \u5927\u4e8e\u6216\u7b49\u4e8e\u8fd0\u7b97\u7b26"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"==")," \u76f8\u7b49\u8fd0\u7b97\u7b26"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"===")," \u4e25\u683c\u76f8\u7b49\u8fd0\u7b97\u7b26"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"!=")," \u4e0d\u76f8\u7b49\u8fd0\u7b97\u7b26"),Object(l.b)("li",{parentName:"ul"},Object(l.b)("inlineCode",{parentName:"li"},"!==")," \u4e25\u683c\u4e0d\u76f8\u7b49\u8fd0\u7b97\u7b26")),Object(l.b)("h4",{id:"\u76f8\u7b49\u8fd0\u7b97\u7b26"},"\u76f8\u7b49\u8fd0\u7b97\u7b26"),Object(l.b)("p",null,"\u76f8\u7b49\u8fd0\u7b97\u7b26\uff08",Object(l.b)("inlineCode",{parentName:"p"},"=="),"\uff09\u6bd4\u8f83\u4e24\u4e2a\u503c\u662f\u5426\u76f8\u7b49\uff0c\u4e25\u683c\u76f8\u7b49\u8fd0\u7b97\u7b26\uff08",Object(l.b)("inlineCode",{parentName:"p"},"==="),"\uff09\u6bd4\u8f83\u5b83\u4eec\u662f\u5426\u4e3a\u201c\u540c\u4e00\u4e2a\u503c\u201d\u3002\u5982\u679c\u4e24\u4e2a\u503c\u4e0d\u662f\u540c\u4e00\u7c7b\u578b\uff0c\u4e25\u683c\u76f8\u7b49\u8fd0\u7b97\u7b26\uff08",Object(l.b)("inlineCode",{parentName:"p"},"==="),"\uff09\u76f4\u63a5\u8fd4\u56de false\uff0c\u800c\u76f8\u7b49\u8fd0\u7b97\u7b26\uff08",Object(l.b)("inlineCode",{parentName:"p"},"=="),"\uff09\u4f1a\u5c06\u5b83\u4eec\u8f6c\u6362\u6210\u540c\u4e00\u4e2a\u7c7b\u578b\uff0c\u518d\u7528\u4e25\u683c\u76f8\u7b49\u8fd0\u7b97\u7b26\u8fdb\u884c\u6bd4\u8f83\u3002"),Object(l.b)("p",null,"\u6bd4\u8f83\u60c5\u51b5\uff1a"),Object(l.b)("ul",null,Object(l.b)("li",{parentName:"ul"},"\u6570\u7ec4 == \u503c\uff0c(\u503c\u7c7b\u578b\u6307\u7684\u662f\u539f\u59cb\u7c7b\u578b)\u4f1a\u5148\u8f6c\u6210\u6570\u503c\u518d\u6bd4\u8f83\uff0c\u4e0e\u5b57\u7b26\u4e32\u6bd4\u8f83\u4f1a\u5148\u8f6c\u6210\u5b57\u7b26\u4e32\u518d\u6bd4\u8f83\u3002"),Object(l.b)("li",{parentName:"ul"},"\u5f15\u7528 == \u503c\uff0c\u4f1a\u628a\u5f15\u7528\u7c7b\u578b\u8f6c\u6210\u539f\u59cb\u7c7b\u578b\u518d\u6bd4\u8f83\u3002"),Object(l.b)("li",{parentName:"ul"},"\u503c == \u503c\uff0c\u76f4\u63a5\u6bd4\u8f83\u7c7b\u578b\u518d\u6bd4\u8f83\u503c\u7684\u5927\u5c0f\u3002"),Object(l.b)("li",{parentName:"ul"},"\u5b57\u7b26\u4e32 == \u6570\u5b57\uff0c\u5219\u628a\u5b57\u7b26\u4e32\u8f6c\u4e3a\u6570\u503c\u518d\u6bd4\u8f83\u3002"),Object(l.b)("li",{parentName:"ul"},"\u5176\u4ed6\u7c7b\u578b == boolean\uff0c\u5219\u628a boolean \u8f6c\u6210\u6570\u503c\u518d\u8fdb\u4e00\u6b65\u6bd4\u8f83\u3002"),Object(l.b)("li",{parentName:"ul"},"undefined == null\uff0c\u4e5f\u4f1a\u53d1\u751f\u9690\u5f0f\u8f6c\u6362\uff0c\u4e14\u4e8c\u8005\u53ef\u4ee5\u76f8\u4e92\u8f6c\u6362\uff0c\u5373\u4e8c\u8005\u76f8\u7b49\uff0c\u4e0e\u81ea\u8eab\u4e5f\u76f8\u7b49\u3002"),Object(l.b)("li",{parentName:"ul"},"\u5bf9\u8c61 == \u975e\u5bf9\u8c61\uff0c\u5982\u679c\u975e\u5bf9\u8c61\u4e3a String\u3001Number \u6216 Symbol\uff0c\u5219\u8fd4\u56de ",Object(l.b)("inlineCode",{parentName:"li"},"ToPrimitive(\u5bf9\u8c61) == \u975e\u5bf9\u8c61"),"\uff0c\u7684\u7ed3\u679c\uff1b",Object(l.b)("inlineCode",{parentName:"li"},"ToPrimitive")," \u65b9\u6cd5\u7684\u53c2\u6570\u5982\u679c\u662f\u539f\u59cb\u7c7b\u578b\u5219\u76f4\u63a5\u8fd4\u56de\uff1b\u5982\u679c\u662f\u5bf9\u8c61\uff0c\u5219\u8c03\u7528 ",Object(l.b)("inlineCode",{parentName:"li"},"valueOf")," \u65b9\u6cd5\uff0c\u5982\u679c\u662f\u539f\u59cb\u503c\u518d\u8fdb\u884c\u539f\u59cb\u7c7b\u578b\u8f6c\u6362\u548c\u5927\u5c0f\u5bf9\u6bd4\uff1b\u5982\u679c\u4e0d\u662f\u539f\u59cb\u503c\u5219\u8c03\u7528 ",Object(l.b)("inlineCode",{parentName:"li"},"toString"),"\uff0c\u4e14\u7ed3\u679c\u4e3a\u539f\u59cb\u503c\u5219\u8fdb\u884c\u539f\u59cb\u7c7b\u578b\u6bd4\u8f83\uff0c\u5982\u679c\u4e0d\u662f\u539f\u59cb\u503c\u5219\u629b\u51fa\u9519\u8bef\u3002")),Object(l.b)("p",null,Object(l.b)("img",{alt:"\u76f8\u7b49\u5143\u7d20\u7b26\u7c7b\u578b\u8f6c\u6362",src:n(281).default})))}j.isMDXComponent=!0}}]);