1\u3001\u4e3a\u4ec0\u4e48\u201cfalse == []\u201d\u548c\u201cfalse == ![]\u201d\u90fd\u8fd4\u56detrue\uff1f <\/strong><\/span><\/div>\n\u670b\u53cb\u4eec\uff0c\u8bf7\u4e0d\u8981\u60ca\u8bb6\u8fd9\u786e\u5b9e\u662f\u6b63\u786e\u7b54\u6848\u3002\u53ea\u8981\u6211\u4eec\u6709\u4e86\u76f8\u7b49\u6bd4\u8f83\u548c\u76f8\u540c\u7684\u77e5\u8bc6\uff0c\u6211\u4eec\u5c31\u80fd\u5b8c\u5168\u7406\u89e3\u5b83\u662f\u600e\u4e48\u4e00\u56de\u4e8b\u4e86\u3002<\/p>\n
console.log(false == []) \/\/ true\r\nconsole.log(false == ![]) \/\/ true\r\n<\/pre>\n\u8ba9\u6211\u7b80\u8981\u89e3\u91ca\u4e00\u4e0b\u5b83\u662f\u5982\u4f55\u5de5\u4f5c\u7684\u3002\u5f53\u6211\u4eec\u9047\u5230\u4e00\u4e2a\u5e03\u5c14\u503c\u548c\u4e00\u4e2a\u5bf9\u8c61\u8fdb\u884c\u6bd4\u8f83\u65f6\uff0c\u4f1a\u5c06\u8fd9\u4e24\u4e2a\u503c\u8f6c\u6362\u4e3a\u6570\u5b57\u8fdb\u884c\u6700\u540e\u7684\u6bd4\u8f83\u3002<\/p>\n
\u6240\u4ee5\u5b83\u4f1a\u7ecf\u5386\u8fd9\u4e9b\u6b65\u9aa4\u3002<\/p>\n
\/\/ 1. Convert false to a number to get 0\r\n\/\/ 2. Convert [] to a number to get 0\r\n\/\/ 3. \"0 == 0\" Returns true\r\nconsole.log(false == []) \/\/ true\r\n\/\/ 1. The result of executing \"![]\" is false\r\n\/\/ 2. false == false Returns true\r\nconsole.log(false == ![]) \/\/ true\r\n<\/pre>\n2. \u4e3a\u4ec0\u4e48\u201c[] == ![]\u201d\u8fd4\u56detrue\uff1f<\/strong><\/span><\/div>\n\u201c1 == !1\u201d\u7684\u7ed3\u679c\u662f\u4ec0\u4e48\uff1f'fatfish' == !'fatfish' \u8fd4\u56de\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u7a7a\u6570\u7ec4\u5982\u6b64\u7279\u522b\uff1f<\/p>\n
\/\/ 1. The result of executing \"![]\" is false\r\n\/\/ 2. Next, compare \"[] == false\"\r\n\/\/ 3. Convert [] to a number to get 0\r\n\/\/ 4. Convert false to a number to get 0\r\n\/\/ 5. \"0 == 0\" Returns true\r\n\r\nconsole.log([] == ![])\r\n<\/pre>\n\u670b\u53cb\u4eec\uff0c\u8bf7\u7528\u201c===\u201d\u4ee3\u66ff\u201c==\u201d\uff0c\u8fd9\u6837\u4f1a\u8ba9\u4f60\u7684\u5de5\u4f5c\u8f7b\u677e\u5f88\u591a\uff0c\u5426\u5219\u4f60\u53ef\u80fd\u4f1a\u505a\u5669\u68a6\u3002<\/p>\n
3.\u5173\u4e8e\u5947\u602a\u7684\u201ctry catch\u201d<\/strong><\/span><\/div>\n\u8bf7\u60f3\u4e00\u60f3\uff0cgetName\u6267\u884c\u8fd4\u56de\u7684\u662f\u4f60\u7684\u597d\u670b\u53cbfatfish\uff0c\u8fd8\u662f\u6211\u4eec\u7684\u597d\u670b\u53cbmedium\uff1f<\/p>\n
const getName = () => {\r\n try {\r\n return 'fatfish'\r\n } finally {\r\n return 'medium'\r\n }\r\n}\r\ngetName() \/\/ ?\r\n<\/pre>\n\u6211\u60f3\u4f60\u731c\u5bf9\u4e86\uff0c\u7b54\u6848\u662f\u201cfatfish\u201d\u3002\u4e0d\uff0c\u4e0d\u662f\uff01\u7b54\u6848\u662f\u201cmedium\u201d\u3002\u8fd9\u662f\u56e0\u4e3a\u5728\u201ctry\u2026.catch\u2026.finally\u201d\u8bed\u53e5\u4e2d\uff0cfinally\u5b50\u53e5\u65e0\u8bba\u662f\u5426\u629b\u51fa\u5f02\u5e38\u90fd\u4f1a\u88ab\u6267\u884c\u3002\u53e6\u5916\uff0c\u5982\u679c\u629b\u51fa\u5f02\u5e38\uff0c\u5373\u4f7f\u6ca1\u6709catch\u5b50\u53e5\u5904\u7406\u5f02\u5e38\uff0cfinally\u5b50\u53e5\u4e2d\u7684\u8bed\u53e5\u4e5f\u4f1a\u88ab\u6267\u884c\u3002<\/p>\n
4.\u5173\u4e8e\u7bad\u5934\u529f\u80fd\uff1f<\/strong><\/span><\/div>\n\u662f\u7684\uff0c\u95ee\u9898\u5f88\u7b80\u5355\uff0c\u4f60\u4f1a\u770b\u5230fatfish\u88ab\u6253\u5370\u51fa\u6765\u4e86\u3002<\/p>\n
const fn = () => 'fatfish'\r\nconsole.log(fn()) \/\/ fatfish\r\n<\/pre>\n\u4f46\u6211\u60f3\u8bf7\u4f60\u5c1d\u8bd5\u56de\u7b54\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u8f93\u51fa\u4ec0\u4e48\uff1f<\/p>\n
const fn = ()\r\nconsole.log(fn()) \/\/ ?\r\n<\/pre>\n\u8bf7\u95ee\u2018{}\u2019\u662f\u6700\u7ec8\u7ed3\u679c\u5417\uff1f\u4e0d\u5e78\u7684\u662f\uff0c\u8fd9\u4e0d\u662f\u6211\u4eec\u60f3\u8c61\u7684\u90a3\u6837\u3002\u672a\u5b9a\u4e49\u7684\u662f\u6700\u540e\u7684\u8d62\u5bb6\u3002<\/p>\n
\u56e0\u4e3a\u2018{}\u2019\u662ffn\u51fd\u6570\u7684\u4e00\u4e2a\u5305\u542b\u5757\uff0c\u6240\u4ee5\u5b83\u7b49\u4ef7\u4e8e\u4e0b\u9762\u7684\u4ee3\u7801\u3002<\/p>\n
const fn = () = {\r\n}\r\n\r\nconsole.log(fn()) \/\/ understand\r\n<\/pre>\n5. \u4e3a\u4ec0\u4e48 JSON.stringify('fatfish') ! ==\u2018fatfish\u2019\uff1f<\/strong><\/span><\/div>\nname1 \u4f1a\u7b49\u4e8e name2 \u5417\uff1f<\/p>\n
const name1 = JSON.stringify('fatfish')\r\nconst name2 = 'fatfish'\r\n\r\nconsole.log(name1 === name2) \/\/ ?\r\n<\/pre>\n\u6211\u771f\u7684\u5f88\u56f0\u60d1\uff0c\u4e3a\u4ec0\u4e48name1\u4e0d\u7b49\u4e8ename2\uff1f<\/p>\n
const name1 = JSON.stringify('fatfish') \/\/ => '\"fatfish\"'\r\nconst name2 = 'fatfish'\r\n\r\nconsole.log(name1 === name2) \/\/ '\"fatfish\"' === 'fatfish' => false\r\n<\/pre>\n\u8bf7\u5c0f\u5fc3\u4f7f\u7528 JSON.stringify \u4e0e\u5b57\u7b26\u4e32\u8fdb\u884c\u6bd4\u8f83\uff0c\u5b83\u4f1a\u8ba9\u60a8\u9677\u5165\u56f0\u5883\u3002<\/p>\n
\u6700\u540e <\/strong><\/div>\n\u8c22\u8c22\u60a8\u7684\u9605\u8bfb\uff0c\u5e76\u671f\u5f85\u60a8\u7684\u5173\u6ce8\uff0c\u60a8\u5c06\u4f1a\u9605\u8bfb\u5230\u66f4\u591a\u6211\u4eec\u63a8\u9001\u7684\u4f18\u8d28\u6587\u7ae0\u5185\u5bb9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
JavaScript \u662f\u4e00\u79cd\u975e\u5e38\u4f18\u79c0\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u4f46\u4e0e\u6b64\u540c\u65f6\uff0c\u5b83\u4e5f\u5e38\u5e38\u8ba9\u6211\u611f\u5230\u56f0\u60d1\u3002\u4e3a\u4ec0\u4e48\u201cfalse == [ […]<\/p>\n","protected":false},"author":643,"featured_media":260041,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-260032","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/260032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/643"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=260032"}],"version-history":[{"count":7,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/260032\/revisions"}],"predecessor-version":[{"id":260040,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/260032\/revisions\/260040"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/260041"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=260032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=260032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=260032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}