{"id":66,"date":"2024-04-10T16:23:41","date_gmt":"2024-04-10T08:23:41","guid":{"rendered":"http:\/\/www.shifengzhi.asia\/?p=66"},"modified":"2024-04-21T15:51:16","modified_gmt":"2024-04-21T07:51:16","slug":"%e5%89%8d%e7%ab%af%e5%ae%9e%e6%88%98%e9%9d%a2%e8%af%95%e9%a2%98","status":"publish","type":"post","link":"https:\/\/boki.shifengzhi.top\/?p=66","title":{"rendered":"\u524d\u7aef\u5b9e\u6218\u9762\u8bd5\u9898"},"content":{"rendered":"<h2>Round One<\/h2>\n<h4>1\u3001\u7b80\u5355\u8bf4\u4e00\u4e0bjs\u4e2d\u7684\u6570\u636e\u7c7b\u578b<\/h4>\n<ul>\n<li>\n<p>\u7b54\uff1a<\/p>\n<p><strong>\u57fa\u672c\u6570\u636e\u7c7b\u578b<\/strong><\/p>\n<ul>\n<li><strong>String:<\/strong> \u5b57\u7b26\u4e32\uff0c\u7528\u5355\u5f15\u53f7\u6216\u53cc\u5f15\u53f7\u5305\u88f9<\/li>\n<li><strong>Number:<\/strong> \u6570\u5b57\uff0c\u5305\u62ec\u6574\u6570\u548c\u5c0f\u6570\uff0c\u4e5f\u5305\u62ec\u7279\u6b8a\u7684\u6570\u503c, \u5982 <code>Infinity<\/code>, <code>-Infinity<\/code> \u548c <code>NaN<\/code><\/li>\n<li><strong>Boolean:<\/strong> \u5e03\u5c14\u503c\uff0c\u53ea\u6709 <code>true<\/code> \u6216 <code>false<\/code><\/li>\n<li><strong>Null:<\/strong> \u7a7a\u503c<\/li>\n<li><strong>Undefined:<\/strong> \u672a\u5b9a\u4e49\u7684\u503c<\/li>\n<\/ul>\n<p><strong>\u5f15\u7528\u6570\u636e\u7c7b\u578b<\/strong><\/p>\n<ul>\n<li><strong>Array:<\/strong> \u5b58\u50a8\u6709\u5e8f\u5143\u7d20\u7684\u96c6\u5408<\/li>\n<li><strong>Object:<\/strong> \u5b58\u50a8\u952e\u503c\u5bf9\u7684\u96c6\u5408<\/li>\n<li><strong>Date:<\/strong> \u8868\u793a\u65e5\u671f\u548c\u65f6\u95f4\u7684\u5bf9\u8c61<\/li>\n<li><strong>RegExp:<\/strong> \u8868\u793a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5bf9\u8c61<\/li>\n<li><strong>Function:<\/strong> \u5b58\u50a8\u4ee3\u7801\u5757\u7684\u5bf9\u8c61<\/li>\n<\/ul>\n<p><strong>ES6 \u65b0\u589e\u6570\u636e\u7c7b\u578b<\/strong><\/p>\n<ul>\n<li><strong>Symbol:<\/strong> \u552f\u4e00\u4e14\u4e0d\u53ef\u53d8\u7684\u503c<\/li>\n<li><strong>BigInt:<\/strong> \u8d85\u8fc7 Number \u8303\u56f4\u7684\u5927\u6574\u6570<\/li>\n<li><strong>Map:<\/strong> \u5b58\u50a8\u952e\u503c\u5bf9\u7684\u96c6\u5408\uff0c\u952e\u53ef\u4ee5\u662f\u4efb\u4f55\u6570\u636e\u7c7b\u578b<\/li>\n<li><strong>Set:<\/strong> \u5b58\u50a8\u552f\u4e00\u503c\u7684\u96c6\u5408<\/li>\n<li><strong>WeakMap:<\/strong> \u5b58\u50a8\u952e\u503c\u5bf9\u7684\u96c6\u5408\uff0c\u952e\u662f\u5f31\u5f15\u7528\uff0c\u4e0d\u4f1a\u963b\u6b62\u5783\u573e\u56de\u6536<\/li>\n<li><strong>WeakSet:<\/strong> \u5b58\u50a8\u552f\u4e00\u503c\u7684\u96c6\u5408\uff0c\u503c\u662f\u5f31\u5f15\u7528\uff0c\u4e0d\u4f1a\u963b\u6b62\u5783\u573e\u56de\u6536<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>2\u3001\u4ec0\u4e48\u662f\u95ed\u5305<\/h4>\n<ul>\n<li>\n<p>\u7b54\uff1a<\/p>\n<p>\u95ed\u5305(Closure)\u6307\u7684\u662f\u4e00\u4e2a\u51fd\u6570\u80fd\u591f\u8bbf\u95ee\u5e76\u64cd\u4f5c\u5b83\u6240\u5b9a\u4e49\u65f6\u6240\u5728\u7684\u5916\u90e8\u51fd\u6570\u4f5c\u7528\u57df\u4e2d\u7684\u53d8\u91cf,\u5373\u4f7f\u5916\u90e8\u51fd\u6570\u5df2\u7ecf\u6267\u884c\u5b8c\u6bd5\u8fd4\u56de\u4e86\u3002<\/p>\n<p>\u95ed\u5305\u7684\u7279\u70b9:<\/p>\n<ol>\n<li><strong>\u51fd\u6570\u5d4c\u5957<\/strong>: \u95ed\u5305\u5fc5\u5b9a\u662f\u4e00\u4e2a\u5185\u90e8\u51fd\u6570,\u5b83\u662f\u5728\u4e00\u4e2a\u5916\u90e8\u51fd\u6570\u4e2d\u5b9a\u4e49\u7684\u3002<\/li>\n<li><strong>\u5916\u90e8\u51fd\u6570\u7684\u53d8\u91cf\u8bbf\u95ee<\/strong>: \u5185\u90e8\u51fd\u6570\u53ef\u4ee5\u8bbf\u95ee\u5e76\u64cd\u4f5c\u5916\u90e8\u51fd\u6570\u4e2d\u7684\u53d8\u91cf,\u5373\u4f7f\u5916\u90e8\u51fd\u6570\u5df2\u7ecf\u6267\u884c\u5b8c\u6bd5\u3002<\/li>\n<li><strong>\u5ef6\u957f\u5916\u90e8\u51fd\u6570\u53d8\u91cf\u7684\u751f\u547d\u5468\u671f<\/strong>: \u7531\u4e8e\u5185\u90e8\u51fd\u6570\u53ef\u4ee5\u8bbf\u95ee\u5916\u90e8\u51fd\u6570\u7684\u53d8\u91cf,\u6240\u4ee5\u5916\u90e8\u51fd\u6570\u7684\u53d8\u91cf\u4e0d\u4f1a\u968f\u7740\u5916\u90e8\u51fd\u6570\u7684\u6267\u884c\u800c\u88ab\u9500\u6bc1,\u800c\u662f\u4f1a\u4e00\u76f4\u5b58\u5728\u4e8e\u5185\u5b58\u4e2d,\u76f4\u5230\u5185\u90e8\u51fd\u6570\u88ab\u9500\u6bc1\u3002<\/li>\n<\/ol>\n<p>\u95ed\u5305\u7684\u4e3b\u8981\u7528\u9014\u5305\u62ec:<\/p>\n<ol>\n<li><strong>\u6570\u636e\u5c01\u88c5\u548c\u79c1\u6709\u53d8\u91cf<\/strong>: \u5229\u7528\u95ed\u5305\u53ef\u4ee5\u521b\u5efa\u79c1\u6709\u53d8\u91cf\u548c\u65b9\u6cd5,\u5b9e\u73b0\u6570\u636e\u7684\u5c01\u88c5\u548c\u9690\u85cf\u3002<\/li>\n<li><strong>\u51fd\u6570\u67ef\u91cc\u5316<\/strong>: \u5229\u7528\u95ed\u5305\u53ef\u4ee5\u5b9e\u73b0\u51fd\u6570\u7684\u67ef\u91cc\u5316,\u4ece\u800c\u5b9e\u73b0\u51fd\u6570\u7684\u90e8\u5206\u6c42\u503c\u3002<\/li>\n<li><strong>\u4e8b\u4ef6\u5904\u7406\u548c\u56de\u8c03\u51fd\u6570<\/strong>: \u5229\u7528\u95ed\u5305\u53ef\u4ee5\u5728\u56de\u8c03\u51fd\u6570\u4e2d\u8bbf\u95ee\u5916\u90e8\u73af\u5883\u7684\u53d8\u91cf\u3002<\/li>\n<li><strong>\u5185\u5b58\u7ba1\u7406<\/strong>: \u7531\u4e8e\u95ed\u5305\u4f1a\u5bfc\u81f4\u539f\u6709\u7684\u4f5c\u7528\u57df\u94fe\u4e0d\u88ab\u91ca\u653e,\u56e0\u6b64\u9700\u8981\u6ce8\u610f\u907f\u514d\u5185\u5b58\u6cc4\u6f0f\u7684\u95ee\u9898\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<h4>3\u3001\u7b80\u8ff0\u4f5c\u7528\u57df\u548c\u4f5c\u7528\u57df\u94fe<\/h4>\n<ul>\n<li>\u7b54\uff1a\n<ol>\n<li><strong>\u4f5c\u7528\u57df(Scope)<\/strong>:\n<ul>\n<li>\u4f5c\u7528\u57df\u662f\u7a0b\u5e8f\u4e2d\u53d8\u91cf\u548c\u51fd\u6570\u7684\u53ef\u89c1\u6027\u548c\u751f\u547d\u5468\u671f\u3002<\/li>\n<li>\u4f5c\u7528\u57df\u5206\u4e3a\u5168\u5c40\u4f5c\u7528\u57df\u548c\u5c40\u90e8\u4f5c\u7528\u57df(\u51fd\u6570\u4f5c\u7528\u57df\u3001\u5757\u7ea7\u4f5c\u7528\u57df)\u3002<\/li>\n<li>\u53d8\u91cf\u5728\u58f0\u660e\u65f6\u5c31\u786e\u5b9a\u4e86\u5b83\u7684\u4f5c\u7528\u57df,\u4f5c\u7528\u57df\u51b3\u5b9a\u4e86\u53d8\u91cf\u7684\u53ef\u89c1\u6027\u3002<\/li>\n<li>\u4f5c\u7528\u57df\u9075\u5faa\u5c31\u8fd1\u539f\u5219,\u5373\u5148\u5728\u5f53\u524d\u4f5c\u7528\u57df\u4e2d\u67e5\u627e\u53d8\u91cf,\u5982\u679c\u6ca1\u6709\u627e\u5230\u5219\u5411\u4e0a\u7ea7\u4f5c\u7528\u57df\u67e5\u627e\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u4f5c\u7528\u57df\u94fe(Scope Chain)<\/strong>:\n<ul>\n<li>\u4f5c\u7528\u57df\u94fe\u662f\u4e00\u4e2a\u7531\u6240\u6709\u7236\u7ea7\u4f5c\u7528\u57df\u7ec4\u6210\u7684\u94fe\u6761\u3002<\/li>\n<li>\u5f53\u5728\u4e00\u4e2a\u4f5c\u7528\u57df\u4e2d\u8bbf\u95ee\u4e00\u4e2a\u53d8\u91cf\u65f6,JavaScript \u5f15\u64ce\u4f1a\u6cbf\u7740\u4f5c\u7528\u57df\u94fe\u5411\u4e0a\u7ea7\u4f5c\u7528\u57df\u67e5\u627e,\u76f4\u5230\u627e\u5230\u8be5\u53d8\u91cf\u6216\u8005\u5230\u8fbe\u5168\u5c40\u4f5c\u7528\u57df\u3002<\/li>\n<li>\u4f5c\u7528\u57df\u94fe\u7684\u65b9\u5411\u662f\u4ece\u5185\u5411\u5916,\u4ece\u5c40\u90e8\u5230\u5168\u5c40\u3002<\/li>\n<li>\u4f5c\u7528\u57df\u94fe\u51b3\u5b9a\u4e86\u6807\u8bc6\u7b26\u7684\u89e3\u6790\u987a\u5e8f,\u4fdd\u8bc1\u4e86\u7a0b\u5e8f\u7684\u6709\u5e8f\u6027\u548c\u6570\u636e\u7684\u5b89\u5168\u6027\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<h4>4\u3001\u7b80\u8ff0CSS\u7684\u91cd\u6392\u548c\u91cd\u7ed8<\/h4>\n<ul>\n<li>\n<p>\u7b54\uff1a<\/p>\n<p><strong>CSS \u91cd\u6392<\/strong><\/p>\n<ul>\n<li>\u5f53 DOM \u7ed3\u6784\u53d1\u751f\u53d8\u5316\u65f6\u89e6\u53d1\u3002<\/li>\n<li>\u6d4f\u89c8\u5668\u5fc5\u987b\u91cd\u65b0\u8ba1\u7b97\u5143\u7d20\u7684\u51e0\u4f55\u5c5e\u6027\uff08\u4f4d\u7f6e\u3001\u5927\u5c0f\u3001\u8fb9\u8ddd\u7b49\uff09\u3002<\/li>\n<li>\u8fd9\u662f\u4e2a\u8017\u65f6\u7684\u8fc7\u7a0b\uff0c\u4f1a\u5bf9\u9875\u9762\u6027\u80fd\u4ea7\u751f\u8d1f\u9762\u5f71\u54cd\u3002<\/li>\n<\/ul>\n<p><strong>CSS \u91cd\u7ed8<\/strong><\/p>\n<ul>\n<li>\u5f53\u5143\u7d20\u7684\u5916\u89c2\u53d1\u751f\u53d8\u5316\uff08\u4f8b\u5982\u989c\u8272\u3001\u80cc\u666f\u3001\u6587\u672c\uff09\u65f6\u89e6\u53d1\u3002<\/li>\n<li>\u6d4f\u89c8\u5668\u5fc5\u987b\u91cd\u65b0\u7ed8\u5236\u53d7\u5f71\u54cd\u7684\u50cf\u7d20\u3002<\/li>\n<li>\u6bd4\u91cd\u6392\u5feb\uff0c\u4f46\u4ecd\u7136\u4f1a\u5f71\u54cd\u6027\u80fd\u3002<\/li>\n<\/ul>\n<p><strong>\u91cd\u6392\u548c\u91cd\u7ed8\u4e4b\u95f4\u7684\u533a\u522b<\/strong><\/p>\n<ul>\n<li><strong>\u89e6\u53d1\u5668\uff1a<\/strong>\u91cd\u6392\u7531 DOM \u7ed3\u6784\u53d8\u5316\u89e6\u53d1\uff0c\u800c\u91cd\u7ed8\u7531\u5143\u7d20\u5916\u89c2\u53d8\u5316\u89e6\u53d1\u3002<\/li>\n<li><strong>\u5f71\u54cd\uff1a<\/strong>\u91cd\u6392\u9700\u8981\u91cd\u65b0\u8ba1\u7b97\u5143\u7d20\u51e0\u4f55\u5c5e\u6027\uff0c\u800c\u91cd\u7ed8\u4ec5\u91cd\u65b0\u7ed8\u5236\u53d7\u5f71\u54cd\u7684\u50cf\u7d20\u3002<\/li>\n<li><strong>\u6027\u80fd\u5f71\u54cd\uff1a<\/strong>\u91cd\u6392\u6bd4\u91cd\u7ed8\u66f4\u8017\u65f6\uff0c\u5bf9\u9875\u9762\u6027\u80fd\u5f71\u54cd\u66f4\u5927\u3002<\/li>\n<\/ul>\n<p><strong>\u4f18\u5316\u91cd\u6392\u548c\u91cd\u7ed8<\/strong><\/p>\n<ul>\n<li>\u907f\u514d\u5728\u5faa\u73af\u4e2d\u9891\u7e41\u4fee\u6539 DOM\u3002<\/li>\n<li>\u4f7f\u7528 CSS \u7c7b\u548c\u8f6c\u6362\u800c\u4e0d\u662f\u5185\u8054\u6837\u5f0f\u3002<\/li>\n<li>\u51cf\u5c11\u5143\u7d20\u5c42\u7ea7\u7ed3\u6784\u3002<\/li>\n<li>\u4f7f\u7528 GPU \u52a0\u901f\uff0c\u4f8b\u5982 CSS <code>translate<\/code> \u548c <code>transform<\/code>\u3002<\/li>\n<li>\u4f7f\u7528 CSS <code>will-change<\/code> \u5c5e\u6027\u901a\u77e5\u6d4f\u89c8\u5668\u5373\u5c06\u53d1\u751f\u7684\u91cd\u6392\u6216\u91cd\u7ed8\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>5\u3001<code>for...in<\/code>\u548c<code>for...of<\/code>\u7684\u533a\u522b<\/h4>\n<ul>\n<li>\n<p>\u7b54\uff1a<\/p>\n<ol>\n<li><strong>\u904d\u5386\u5bf9\u8c61\u4e0e\u904d\u5386\u6570\u7ec4<\/strong>:\n<ul>\n<li><code>for...in<\/code> \u5faa\u73af\u7528\u4e8e\u904d\u5386\u5bf9\u8c61\u7684\u53ef\u679a\u4e3e\u5c5e\u6027,\u5305\u62ec\u4ece\u539f\u578b\u7ee7\u627f\u7684\u5c5e\u6027\u3002<\/li>\n<li><code>for...of<\/code> \u5faa\u73af\u7528\u4e8e\u904d\u5386\u53ef\u8fed\u4ee3\u5bf9\u8c61(\u5982\u6570\u7ec4\u3001\u5b57\u7b26\u4e32\u3001NodeList \u7b49),\u5b83\u4f1a\u904d\u5386\u5bf9\u8c61\u7684\u5143\u7d20\u503c\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u904d\u5386\u987a\u5e8f<\/strong>:\n<ul>\n<li><code>for...in<\/code> \u5faa\u73af\u7684\u904d\u5386\u987a\u5e8f\u662f\u4e0d\u786e\u5b9a\u7684,\u56e0\u4e3a\u5b83\u4f1a\u904d\u5386\u5bf9\u8c61\u7684\u6240\u6709\u53ef\u679a\u4e3e\u5c5e\u6027,\u5305\u62ec\u4ece\u539f\u578b\u7ee7\u627f\u7684\u5c5e\u6027\u3002<\/li>\n<li><code>for...of<\/code> \u5faa\u73af\u4f1a\u6309\u7167\u6570\u636e\u7ed3\u6784\u7684\u81ea\u7136\u987a\u5e8f\u8fdb\u884c\u904d\u5386,\u5bf9\u4e8e\u6570\u7ec4\u6765\u8bf4\u5c31\u662f\u7d22\u5f15\u987a\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u904d\u5386\u5bf9\u8c61\u5c5e\u6027<\/strong>:\n<ul>\n<li><code>for...in<\/code> \u5faa\u73af\u53ef\u4ee5\u904d\u5386\u5bf9\u8c61\u7684\u6240\u6709\u53ef\u679a\u4e3e\u5c5e\u6027,\u5305\u62ec\u4ece\u539f\u578b\u7ee7\u627f\u7684\u5c5e\u6027\u3002<\/li>\n<li><code>for...of<\/code> \u5faa\u73af\u65e0\u6cd5\u76f4\u63a5\u904d\u5386\u5bf9\u8c61\u7684\u5c5e\u6027,\u56e0\u4e3a\u5bf9\u8c61\u4e0d\u662f\u53ef\u8fed\u4ee3\u7684\u3002\u5982\u679c\u9700\u8981\u904d\u5386\u5bf9\u8c61\u7684\u5c5e\u6027,\u53ef\u4ee5\u4f7f\u7528 <code>Object.keys()<\/code>, <code>Object.values()<\/code> \u6216 <code>Object.entries()<\/code> \u914d\u5408 <code>for...of<\/code> \u5faa\u73af\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u904d\u5386\u6027\u80fd<\/strong>:\n<ul>\n<li>\u4e00\u822c\u6765\u8bf4,<code>for...of<\/code> \u5faa\u73af\u7684\u6027\u80fd\u8981\u4f18\u4e8e <code>for...in<\/code> \u5faa\u73af,\u56e0\u4e3a <code>for...in<\/code> \u5faa\u73af\u9700\u8981\u68c0\u67e5\u539f\u578b\u94fe\u4e0a\u7684\u5c5e\u6027,\u800c <code>for...of<\/code> \u5faa\u73af\u53ea\u9700\u8981\u904d\u5386\u53ef\u8fed\u4ee3\u5bf9\u8c61\u7684\u5143\u7d20\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u603b\u7684\u6765\u8bf4,<code>for...in<\/code> \u66f4\u9002\u5408\u904d\u5386\u5bf9\u8c61\u5c5e\u6027,\u800c <code>for...of<\/code> \u66f4\u9002\u5408\u904d\u5386\u6570\u7ec4\u6216\u5176\u4ed6\u53ef\u8fed\u4ee3\u5bf9\u8c61\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>6\u3001<code>for item in \u5bf9\u8c61<\/code>\u904d\u5386\u65f6\uff0citem\u662f\u4ec0\u4e48\uff1f<\/h4>\n<ul>\n<li>\n<p>\u7b54\uff1a<\/p>\n<p><code>for...in<\/code> \u5faa\u73af\u904d\u5386\u5bf9\u8c61\u65f6,<code>item<\/code> \u53d8\u91cf\u8868\u793a\u7684\u662f\u5bf9\u8c61\u7684<strong>\u952e(key)<\/strong>,\u800c\u4e0d\u662f\u503c(value)\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>7\u3001<code>v-if<\/code>\u548c<code>v-show<\/code>\u7684\u533a\u522b\uff1f\u54ea\u4e2a\u6027\u80fd\u66f4\u597d\uff1f<\/h4>\n<ul>\n<li>\n<p>\u7b54\uff1a<\/p>\n<ol>\n<li><strong>\u6e32\u67d3\u65b9\u5f0f<\/strong>:\n<ul>\n<li><code>v-if<\/code>: \u5f53\u6761\u4ef6\u4e3a false \u65f6,\u5143\u7d20\u4e0d\u4f1a\u88ab\u6e32\u67d3\u5230 DOM \u4e2d\u3002\u5b83\u4f1a\u6839\u636e\u6761\u4ef6\u52a8\u6001\u5730\u521b\u5efa\u6216\u9500\u6bc1\u5143\u7d20\u3002<\/li>\n<li><code>v-show<\/code>: \u5f53\u6761\u4ef6\u4e3a false \u65f6,\u5143\u7d20\u7684 <code>display<\/code> \u5c5e\u6027\u4f1a\u88ab\u8bbe\u7f6e\u4e3a <code>none<\/code>\u3002\u5143\u7d20\u4ecd\u7136\u5b58\u5728\u4e8e DOM \u4e2d,\u53ea\u662f\u88ab\u9690\u85cf\u4e86\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u521d\u59cb\u6e32\u67d3\u6027\u80fd<\/strong>:\n<ul>\n<li><code>v-if<\/code>: \u53ea\u6709\u5f53\u6761\u4ef6\u4e3a true \u65f6,\u5143\u7d20\u624d\u4f1a\u88ab\u6e32\u67d3\u3002\u8fd9\u610f\u5473\u7740\u521d\u59cb\u6e32\u67d3\u65f6,<code>v-if<\/code> \u4f1a\u66f4\u5feb\u4e00\u4e9b\u3002<\/li>\n<li><code>v-show<\/code>: \u5143\u7d20\u59cb\u7ec8\u4f1a\u88ab\u6e32\u67d3\u5230 DOM \u4e2d,\u53ea\u662f\u901a\u8fc7 CSS \u5c5e\u6027\u8fdb\u884c\u9690\u85cf\u3002\u8fd9\u610f\u5473\u7740\u521d\u59cb\u6e32\u67d3\u65f6,<code>v-show<\/code> \u4f1a\u66f4\u6162\u4e00\u4e9b\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5207\u6362\u6027\u80fd<\/strong>:\n<ul>\n<li><code>v-if<\/code>: \u6bcf\u6b21\u6761\u4ef6\u53d8\u5316\u65f6,\u90fd\u4f1a\u9500\u6bc1\u548c\u521b\u5efa\u5143\u7d20\u3002\u5bf9\u4e8e\u9891\u7e41\u5207\u6362\u7684\u573a\u666f,<code>v-if<\/code> \u4f1a\u6bd4 <code>v-show<\/code> \u6162\u3002<\/li>\n<li><code>v-show<\/code>: \u5143\u7d20\u53ea\u9700\u8981\u901a\u8fc7\u4fee\u6539 CSS \u5c5e\u6027\u6765\u5207\u6362\u53ef\u89c1\u6027,\u8fd9\u901a\u5e38\u6bd4\u9500\u6bc1\u548c\u521b\u5efa\u5143\u7d20\u5feb\u5f97\u591a\u3002\u5bf9\u4e8e\u9891\u7e41\u5207\u6362\u7684\u573a\u666f,<code>v-show<\/code> \u4f1a\u66f4\u5feb\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u751f\u547d\u5468\u671f<\/strong>:\n<ul>\n<li><code>v-if<\/code>: \u5f53\u6761\u4ef6\u4e3a false \u65f6,\u5143\u7d20\u53ca\u5176\u5b50\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50\u90fd\u4e0d\u4f1a\u88ab\u89e6\u53d1\u3002<\/li>\n<li><code>v-show<\/code>: \u5143\u7d20\u53ca\u5176\u5b50\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50\u4f1a\u4e00\u76f4\u88ab\u89e6\u53d1,\u65e0\u8bba\u6761\u4ef6\u662f\u5426\u6ee1\u8db3\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u603b\u7684\u6765\u8bf4:<\/p>\n<ul>\n<li>\u5982\u679c\u9700\u8981\u5728\u8fd0\u884c\u65f6\u5f88\u5c11\u6539\u53d8\u6761\u4ef6\u7684\u573a\u666f\u4e2d,\u4f7f\u7528 <code>v-if<\/code> \u4f1a\u66f4\u5408\u9002,\u56e0\u4e3a\u5b83\u53ef\u4ee5\u786e\u4fdd\u6761\u4ef6\u5757\u5185\u7684\u4e8b\u4ef6\u76d1\u542c\u5668\u548c\u5b50\u7ec4\u4ef6\u9002\u5f53\u5730\u88ab\u9500\u6bc1\u548c\u91cd\u5efa\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u9891\u7e41\u5207\u6362\u6761\u4ef6\u7684\u573a\u666f\u4e2d,\u4f7f\u7528 <code>v-show<\/code> \u4f1a\u66f4\u5408\u9002,\u56e0\u4e3a\u5b83\u4e0d\u4f1a\u9500\u6bc1\u548c\u91cd\u5efa\u5143\u7d20,\u6027\u80fd\u4f1a\u66f4\u597d\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>8\u3001\u7b80\u5355\u8bf4\u4e00\u4e0b\u5feb\u901f\u6392\u5e8f\u7684\u8fc7\u7a0b<\/h4>\n<ul>\n<li>\n<p>\u7b54\uff1a<\/p>\n<ol>\n<li>\u4ece\u6570\u5217\u4e2d\u6311\u51fa\u4e00\u4e2a\u5143\u7d20\u4f5c\u4e3a\u57fa\u51c6(pivot)\u3002<\/li>\n<li>\u5c06\u6240\u6709\u6bd4\u57fa\u51c6\u5c0f\u7684\u5143\u7d20\u653e\u5728\u57fa\u51c6\u5de6\u8fb9,\u6240\u6709\u6bd4\u57fa\u51c6\u5927\u7684\u5143\u7d20\u653e\u5728\u57fa\u51c6\u53f3\u8fb9\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u79f0\u4e3a\u5206\u533a(partition)\u64cd\u4f5c\u3002<\/li>\n<li>\u9012\u5f52\u5730(recursive)\u628a\u5de6\u53f3\u4e24\u4e2a\u5c0f\u95ee\u9898\u6392\u5e8f\u3002<\/li>\n<\/ol>\n<p>\u62d3\u5c55\uff1a<\/p>\n<pre><code class=\"language-javascript\">function quickSort(arr) {\nif (arr.length <= 1) {\n  return arr;\n}\n\nconst pivotIndex = Math.floor(arr.length \/ 2);\nconst pivot = arr.splice(pivotIndex, 1)[0];\nconst left = [];\nconst right = [];\n\nfor (let i = 0; i < arr.length; i++) {\n  if (arr[i] < pivot) {\n    left.push(arr[i]);\n  } else {\n    right.push(arr[i]);\n  }\n}\n\nreturn quickSort(left).concat([pivot], quickSort(right));\n}\n\n\/\/ \u4f7f\u7528\u793a\u4f8b\nconst unsortedArray = [5, 2, 9, 1, 7, 3, 8, 4, 6];\nconst sortedArray = quickSort(unsortedArray);\nconsole.log(sortedArray); \/\/ \u8f93\u51fa: [1, 2, 3, 4, 5, 6, 7, 8, 9]<\/code><\/pre>\n<p>\u8fd9\u4e2a\u5b9e\u73b0\u9075\u5faa\u4e86\u5feb\u901f\u6392\u5e8f\u7684\u57fa\u672c\u6b65\u9aa4:<\/p>\n<ol>\n<li>\u5982\u679c\u6570\u7ec4\u957f\u5ea6\u5c0f\u4e8e\u6216\u7b49\u4e8e 1,\u76f4\u63a5\u8fd4\u56de\u8be5\u6570\u7ec4\u3002<\/li>\n<li>\u9009\u62e9\u6570\u7ec4\u4e2d\u95f4\u7684\u5143\u7d20\u4f5c\u4e3a\u57fa\u51c6\u70b9(pivot)\u3002<\/li>\n<li>\u5c06\u6570\u7ec4\u5206\u6210\u4e24\u90e8\u5206:\u5c0f\u4e8e\u57fa\u51c6\u70b9\u7684\u5143\u7d20\u653e\u5728\u5de6\u8fb9\u6570\u7ec4,\u5927\u4e8e\u6216\u7b49\u4e8e\u57fa\u51c6\u70b9\u7684\u5143\u7d20\u653e\u5728\u53f3\u8fb9\u6570\u7ec4\u3002<\/li>\n<li>\u9012\u5f52\u5730\u5bf9\u5de6\u53f3\u4e24\u4e2a\u5b50\u6570\u7ec4\u8fdb\u884c\u5feb\u901f\u6392\u5e8f\u3002<\/li>\n<li>\u6700\u540e\u5c06\u5de6\u53f3\u4e24\u4e2a\u6392\u597d\u5e8f\u7684\u5b50\u6570\u7ec4\u5408\u5e76\u8d77\u6765,\u5373\u5f97\u5230\u6392\u597d\u5e8f\u7684\u6570\u7ec4\u3002<\/li>\n<\/ol>\n<p>\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a O(n log n),\u662f\u4e00\u79cd\u975e\u5e38\u9ad8\u6548\u7684\u6392\u5e8f\u7b97\u6cd5\u3002<\/p>\n<\/li>\n<\/ul>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>Round One 1\u3001\u7b80\u5355\u8bf4\u4e00\u4e0bjs\u4e2d\u7684\u6570\u636e\u7c7b\u578b \u7b54\uff1a \u57fa\u672c\u6570\u636e\u7c7b\u578b String: \u5b57\u7b26\u4e32\uff0c\u7528\u5355\u5f15\u53f7\u6216\u53cc\u5f15 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[19],"class_list":["post-66","post","type-post","status-publish","format-standard","hentry","category-5","tag-19"],"_links":{"self":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=66"}],"version-history":[{"count":2,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions"}],"predecessor-version":[{"id":68,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions\/68"}],"wp:attachment":[{"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/boki.shifengzhi.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}