{"id":227,"date":"2026-03-07T23:51:41","date_gmt":"2026-03-07T15:51:41","guid":{"rendered":"https:\/\/www.resilence.cn\/?p=227"},"modified":"2026-03-07T23:51:41","modified_gmt":"2026-03-07T15:51:41","slug":"day-5-%e5%87%bd%e6%95%b0%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"https:\/\/www.resilence.cn\/?p=227","title":{"rendered":"Day-5-\u51fd\u6570\u5165\u95e8"},"content":{"rendered":"<h1>Day 5: \u51fd\u6570\u5165\u95e8<\/h1>\n<h2>\ud83c\udfaf \u5b66\u4e60\u76ee\u6807<\/h2>\n<ul>\n<li>\u7406\u89e3\u51fd\u6570\u7684\u6982\u5ff5\u548c\u4f5c\u7528<\/li>\n<li>\u638c\u63e1\u51fd\u6570\u7684\u58f0\u660e\u3001\u8c03\u7528\u548c\u53c2\u6570\u4f20\u9012<\/li>\n<li>\u5b66\u4f1a\u4f7f\u7528\u8fd4\u56de\u503c\u548c\u4f5c\u7528\u57df<\/li>\n<li>\u7406\u89e3\u56de\u8c03\u51fd\u6570\u7684\u5e94\u7528<\/li>\n<\/ul>\n<h2>\ud83d\udca1 \u6838\u5fc3\u6982\u5ff5<\/h2>\n<h3>\u4ec0\u4e48\u662f\u51fd\u6570\uff1f<\/h3>\n<p>\u51fd\u6570\u662f\u4e00\u6bb5\u53ef\u4ee5\u91cd\u590d\u4f7f\u7528\u7684\u4ee3\u7801\u5757\uff0c\u5b83\u63a5\u6536\u8f93\u5165\uff08\u53c2\u6570\uff09\uff0c\u8fdb\u884c\u5904\u7406\uff0c\u7136\u540e\u8fd4\u56de\u8f93\u51fa\uff08\u8fd4\u56de\u503c\uff09\u3002\u51fd\u6570\u662f\u7f16\u7a0b\u4e2d\u6700\u57fa\u672c\u7684\u4ee3\u7801\u7ec4\u7ec7\u65b9\u5f0f\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u9700\u8981\u51fd\u6570\uff1f<\/h3>\n<h4>1. <strong>\u4ee3\u7801\u590d\u7528<\/strong><\/h4>\n<pre><code class=\"language-javascript\">\/\/ \u274c \u91cd\u590d\u4ee3\u7801\nconsole.log(&quot;Hello, Alice!&quot;);\nconsole.log(&quot;Hello, Bob!&quot;);\nconsole.log(&quot;Hello, Charlie!&quot;);\n\n\/\/ \u2705 \u4f7f\u7528\u51fd\u6570\nfunction greet(name) {\n    console.log(`Hello, ${name}!`);\n}\ngreet(&quot;Alice&quot;);\ngreet(&quot;Bob&quot;);\ngreet(&quot;Charlie&quot;);\n<\/code><\/pre>\n<h4>2. <strong>\u903b\u8f91\u5c01\u88c5<\/strong><\/h4>\n<p>\u5c06\u590d\u6742\u7684\u64cd\u4f5c\u5c01\u88c5\u6210\u51fd\u6570\uff0c\u63d0\u9ad8\u4ee3\u7801\u53ef\u8bfb\u6027\u3002<\/p>\n<h4>3. <strong>\u6a21\u5757\u5316\u5f00\u53d1<\/strong><\/h4>\n<p>\u5c06\u7a0b\u5e8f\u5206\u89e3\u4e3a\u591a\u4e2a\u5c0f\u51fd\u6570\uff0c\u4fbf\u4e8e\u5f00\u53d1\u548c\u7ef4\u62a4\u3002<\/p>\n<h2>\ud83d\udcdd \u51fd\u6570\u57fa\u7840<\/h2>\n<h3>1. \u51fd\u6570\u58f0\u660e<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u51fd\u6570\u58f0\u660e\uff08Function Declaration\uff09\nfunction functionName(parameter1, parameter2) {\n    \/\/ \u51fd\u6570\u4f53\n    return result;\n}\n\n\/\/ \u793a\u4f8b\nfunction add(a, b) {\n    return a + b;\n}\n<\/code><\/pre>\n<h3>2. \u51fd\u6570\u8868\u8fbe\u5f0f<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u51fd\u6570\u8868\u8fbe\u5f0f\uff08Function Expression\uff09\nconst functionName = function(parameter1, parameter2) {\n    \/\/ \u51fd\u6570\u4f53\n    return result;\n};\n\n\/\/ \u793a\u4f8b\nconst multiply = function(a, b) {\n    return a * b;\n};\n<\/code><\/pre>\n<h3>3. \u7bad\u5934\u51fd\u6570\uff08ES6\uff09<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u7bad\u5934\u51fd\u6570\uff08Arrow Function\uff09\nconst functionName = (parameter1, parameter2) =&gt; {\n    \/\/ \u51fd\u6570\u4f53\n    return result;\n};\n\n\/\/ \u7b80\u5199\uff08\u5355\u884c\u8fd4\u56de\uff09\nconst subtract = (a, b) =&gt; a - b;\n\n\/\/ \u65e0\u53c2\u6570\nconst sayHello = () =&gt; console.log(&quot;Hello!&quot;);\n\n\/\/ \u5355\u53c2\u6570\uff08\u62ec\u53f7\u53ef\u7701\u7565\uff09\nconst square = x =&gt; x * x;\n<\/code><\/pre>\n<h2>\ud83c\udfae \u53c2\u6570\u8be6\u89e3<\/h2>\n<h3>1. \u9ed8\u8ba4\u53c2\u6570<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u8bbe\u7f6e\u9ed8\u8ba4\u503c\nfunction greet(name = &quot;World&quot;) {\n    console.log(`Hello, ${name}!`);\n}\n\ngreet();          \/\/ &quot;Hello, World!&quot;\ngreet(&quot;Alice&quot;);   \/\/ &quot;Hello, Alice!&quot;\n<\/code><\/pre>\n<h3>2. \u5269\u4f59\u53c2\u6570\uff08Rest Parameters\uff09<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u4f7f\u7528 ... \u6536\u96c6\u6240\u6709\u53c2\u6570\nfunction sum(...numbers) {\n    return numbers.reduce((total, num) =&gt; total + num, 0);\n}\n\nsum(1, 2, 3);           \/\/ 6\nsum(1, 2, 3, 4, 5);     \/\/ 15\n<\/code><\/pre>\n<h3>3. \u89e3\u6784\u53c2\u6570<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u5bf9\u8c61\u89e3\u6784\nfunction createUser({name, age, city}) {\n    console.log(`${name}, ${age}\u5c81\uff0c\u6765\u81ea${city}`);\n}\n\ncreateUser({name: &quot;\u5f20\u4e09&quot;, age: 25, city: &quot;\u5317\u4eac&quot;});\n\n\/\/ \u6570\u7ec4\u89e3\u6784\nfunction swap([first, second]) {\n    return [second, first];\n}\n<\/code><\/pre>\n<h2>\ud83d\udd04 \u8fd4\u56de\u503c<\/h2>\n<h3>1. return \u8bed\u53e5<\/h3>\n<pre><code class=\"language-javascript\">function calculate(price, quantity) {\n    const total = price * quantity;\n    return total;  \/\/ \u8fd4\u56de\u7ed3\u679c\n}\n\nconst result = calculate(10, 5);  \/\/ 50\n<\/code><\/pre>\n<h3>2. \u65e9\u671f\u8fd4\u56de<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u2705 \u597d\u7684\u5b9e\u8df5\uff1a\u65e9\u671f\u8fd4\u56de\nfunction getUserRole(user) {\n    if (!user) {\n        return &quot;Guest&quot;;  \/\/ \u672a\u767b\u5f55\u8fd4\u56de Guest\n    }\n    if (user.isAdmin) {\n        return &quot;Admin&quot;;\n    }\n    return &quot;User&quot;;\n}\n\n\/\/ \u274c \u4e0d\u597d\u7684\u5b9e\u8df5\uff1a\u6df1\u5c42\u5d4c\u5957\nfunction getUserRole(user) {\n    if (user) {\n        if (user.isAdmin) {\n            return &quot;Admin&quot;;\n        } else {\n            return &quot;User&quot;;\n        }\n    } else {\n        return &quot;Guest&quot;;\n    }\n}\n<\/code><\/pre>\n<h3>3. \u8fd4\u56de\u591a\u4e2a\u503c<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u8fd4\u56de\u6570\u7ec4\nfunction getMinMax(numbers) {\n    return [Math.min(...numbers), Math.max(...numbers)];\n}\n\nconst [min, max] = getMinMax([1, 2, 3, 4, 5]);\n\n\/\/ \u8fd4\u56de\u5bf9\u8c61\uff08\u66f4\u6e05\u6670\uff09\nfunction getPersonInfo(name) {\n    return {\n        firstName: name.split(&quot; &quot;)[0],\n        lastName: name.split(&quot; &quot;)[1],\n        length: name.length\n    };\n}\n<\/code><\/pre>\n<h2>\ud83d\udce6 \u4f5c\u7528\u57df<\/h2>\n<h3>1. \u5168\u5c40\u4f5c\u7528\u57df vs \u5c40\u90e8\u4f5c\u7528\u57df<\/h3>\n<pre><code class=\"language-javascript\">const globalVar = &quot;\u5168\u5c40\u53d8\u91cf&quot;;\n\nfunction testScope() {\n    const localVar = &quot;\u5c40\u90e8\u53d8\u91cf&quot;;\n    console.log(globalVar);  \/\/ \u2705 \u53ef\u4ee5\u8bbf\u95ee\n    console.log(localVar);   \/\/ \u2705 \u53ef\u4ee5\u8bbf\u95ee\n}\n\nconsole.log(globalVar);  \/\/ \u2705 \u53ef\u4ee5\u8bbf\u95ee\nconsole.log(localVar);   \/\/ \u274c \u62a5\u9519\uff1a\u672a\u5b9a\u4e49\n<\/code><\/pre>\n<h3>2. \u53d8\u91cf\u906e\u853d<\/h3>\n<pre><code class=\"language-javascript\">const x = 10;  \/\/ \u5168\u5c40\u53d8\u91cf\n\nfunction example() {\n    const x = 20;  \/\/ \u5c40\u90e8\u53d8\u91cf\uff0c\u906e\u853d\u5168\u5c40\u53d8\u91cf\n    console.log(x);  \/\/ 20\n}\n\nexample();\nconsole.log(x);  \/\/ 10\n<\/code><\/pre>\n<h3>3. \u5757\u7ea7\u4f5c\u7528\u57df\uff08let \u548c const\uff09<\/h3>\n<pre><code class=\"language-javascript\">function test() {\n    if (true) {\n        const blockScoped = &quot;\u5757\u7ea7\u53d8\u91cf&quot;;\n        let blockLet = &quot;\u4e5f\u662f\u5757\u7ea7\u53d8\u91cf&quot;;\n        var functionScoped = &quot;\u51fd\u6570\u7ea7\u53d8\u91cf&quot;;\n    }\n\n    \/\/ console.log(blockScoped);  \/\/ \u274c \u62a5\u9519\n    \/\/ console.log(blockLet);     \/\/ \u274c \u62a5\u9519\n    console.log(functionScoped);  \/\/ \u2705 \u53ef\u4ee5\u8bbf\u95ee\n}\n<\/code><\/pre>\n<h2>\ud83c\udfaf \u5b9e\u6218\u793a\u4f8b<\/h2>\n<h3>\u793a\u4f8b 1\uff1a\u8868\u5355\u9a8c\u8bc1\u51fd\u6570<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u9a8c\u8bc1\u90ae\u7bb1\nfunction validateEmail(email) {\n    const regex = \/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/;\n    return regex.test(email);\n}\n\n\/\/ \u9a8c\u8bc1\u5bc6\u7801\u5f3a\u5ea6\nfunction validatePassword(password) {\n    if (password.length &lt; 8) {\n        return {valid: false, message: &quot;\u5bc6\u7801\u81f3\u5c118\u4f4d&quot;};\n    }\n    if (!\/[A-Z]\/.test(password)) {\n        return {valid: false, message: &quot;\u9700\u8981\u5305\u542b\u5927\u5199\u5b57\u6bcd&quot;};\n    }\n    if (!\/[0-9]\/.test(password)) {\n        return {valid: false, message: &quot;\u9700\u8981\u5305\u542b\u6570\u5b57&quot;};\n    }\n    return {valid: true, message: &quot;\u5bc6\u7801\u5f3a\u5ea6\u5408\u683c&quot;};\n}\n\n\/\/ \u4f7f\u7528\nconst email = &quot;user@example.com&quot;;\nif (validateEmail(email)) {\n    console.log(&quot;\u90ae\u7bb1\u683c\u5f0f\u6b63\u786e&quot;);\n}\n<\/code><\/pre>\n<h3>\u793a\u4f8b 2\uff1aDOM \u64cd\u4f5c\u5c01\u88c5<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u521b\u5efa\u5143\u7d20\u7684\u8f85\u52a9\u51fd\u6570\nfunction createElement(tag, options = {}) {\n    const element = document.createElement(tag);\n\n    \/\/ \u8bbe\u7f6e\u5c5e\u6027\n    if (options.id) element.id = options.id;\n    if (options.className) element.className = options.className;\n    if (options.text) element.textContent = options.text;\n    if (options.html) element.innerHTML = options.html;\n\n    \/\/ \u6dfb\u52a0\u4e8b\u4ef6\u76d1\u542c\n    if (options.onClick) {\n        element.addEventListener('click', options.onClick);\n    }\n\n    return element;\n}\n\n\/\/ \u4f7f\u7528\nconst button = createElement('button', {\n    text: '\u70b9\u51fb\u6211',\n    className: 'btn btn-primary',\n    onClick: () =&gt; alert('\u88ab\u70b9\u51fb\u4e86!')\n});\n\ndocument.body.appendChild(button);\n<\/code><\/pre>\n<h3>\u793a\u4f8b 3\uff1a\u6570\u636e\u8f6c\u6362\u51fd\u6570<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u683c\u5f0f\u5316\u8d27\u5e01\nfunction formatCurrency(amount, currency = 'CNY') {\n    const symbols = {\n        'CNY': '\u00a5',\n        'USD': '$',\n        'EUR': '\u20ac'\n    };\n    return `${symbols[currency]}${amount.toFixed(2)}`;\n}\n\n\/\/ \u683c\u5f0f\u5316\u65e5\u671f\nfunction formatDate(date, format = 'YYYY-MM-DD') {\n    const year = date.getFullYear();\n    const month = String(date.getMonth() + 1).padStart(2, '0');\n    const day = String(date.getDate()).padStart(2, '0');\n\n    return format\n        .replace('YYYY', year)\n        .replace('MM', month)\n        .replace('DD', day);\n}\n\n\/\/ \u4f7f\u7528\nconsole.log(formatCurrency(99.9));              \/\/ &quot;\u00a599.90&quot;\nconsole.log(formatDate(new Date()));            \/\/ &quot;2026-03-07&quot;\n<\/code><\/pre>\n<h2>\ud83d\udd04 \u56de\u8c03\u51fd\u6570<\/h2>\n<h3>\u4ec0\u4e48\u662f\u56de\u8c03\u51fd\u6570\uff1f<\/h3>\n<p>\u56de\u8c03\u51fd\u6570\u662f\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u53e6\u4e00\u4e2a\u51fd\u6570\u7684\u51fd\u6570\uff0c\u5728\u7279\u5b9a\u4e8b\u4ef6\u53d1\u751f\u65f6\u88ab\u8c03\u7528\u3002<\/p>\n<pre><code class=\"language-javascript\">\/\/ \u5b9a\u65f6\u5668\u56de\u8c03\nsetTimeout(() =&gt; {\n    console.log(&quot;1\u79d2\u540e\u6267\u884c&quot;);\n}, 1000);\n\n\/\/ \u6570\u7ec4\u65b9\u6cd5\u56de\u8c03\nconst numbers = [1, 2, 3, 4, 5];\nconst doubled = numbers.map(num =&gt; num * 2);  \/\/ [2, 4, 6, 8, 10]\n\n\/\/ \u4e8b\u4ef6\u76d1\u542c\u56de\u8c03\nbutton.addEventListener('click', function() {\n    console.log(&quot;\u6309\u94ae\u88ab\u70b9\u51fb&quot;);\n});\n<\/code><\/pre>\n<h3>\u81ea\u5b9a\u4e49\u56de\u8c03\u51fd\u6570<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u6570\u636e\u52a0\u8f7d\u51fd\u6570\uff08\u6a21\u62df\u5f02\u6b65\uff09\nfunction loadData(callback) {\n    console.log(&quot;\u5f00\u59cb\u52a0\u8f7d\u6570\u636e...&quot;);\n    setTimeout(() =&gt; {\n        const data = {name: &quot;\u5f20\u4e09&quot;, age: 25};\n        callback(data);  \/\/ \u6570\u636e\u52a0\u8f7d\u5b8c\u6210\u540e\u8c03\u7528\u56de\u8c03\n    }, 1000);\n}\n\n\/\/ \u4f7f\u7528\nloadData(function(data) {\n    console.log(&quot;\u6570\u636e\u52a0\u8f7d\u5b8c\u6210:&quot;, data);\n});\n<\/code><\/pre>\n<h2>\u26a0\ufe0f \u5e38\u89c1\u9519\u8bef<\/h2>\n<h3>1. \u5fd8\u8bb0 return<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u274c \u9519\u8bef\uff1a\u6ca1\u6709 return\nfunction add(a, b) {\n    a + b;\n}\nconsole.log(add(2, 3));  \/\/ undefined\n\n\/\/ \u2705 \u6b63\u786e\uff1a\u52a0\u4e0a return\nfunction add(a, b) {\n    return a + b;\n}\nconsole.log(add(2, 3));  \/\/ 5\n<\/code><\/pre>\n<h3>2. \u4fee\u6539\u5168\u5c40\u53d8\u91cf<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u274c \u4e0d\u597d\uff1a\u4fee\u6539\u5168\u5c40\u53d8\u91cf\nlet count = 0;\nfunction increment() {\n    count++;\n}\n\n\/\/ \u2705 \u66f4\u597d\uff1a\u4f7f\u7528\u53c2\u6570\u548c\u8fd4\u56de\u503c\nfunction increment(count) {\n    return count + 1;\n}\n<\/code><\/pre>\n<h3>3. \u53c2\u6570\u8fc7\u591a<\/h3>\n<pre><code class=\"language-javascript\">\/\/ \u274c \u53c2\u6570\u592a\u591a\uff0c\u96be\u4ee5\u7ef4\u62a4\nfunction createUser(name, age, email, phone, address, city) {\n    \/\/ ...\n}\n\n\/\/ \u2705 \u4f7f\u7528\u5bf9\u8c61\u53c2\u6570\nfunction createUser(options) {\n    const {name, age, email, phone, address, city} = options;\n    \/\/ ...\n}\n<\/code><\/pre>\n<h2>\u270d\ufe0f \u7ec3\u4e60\u4efb\u52a1<\/h2>\n<h3>\u7ec3\u4e60 1\uff1a\u57fa\u7840\u51fd\u6570<\/h3>\n<p>\u521b\u5efa\u4ee5\u4e0b\u51fd\u6570\uff1a<\/p>\n<ol>\n<li><code>celsiusToFahrenheit(celsius)<\/code> &#8211; \u6444\u6c0f\u5ea6\u8f6c\u534e\u6c0f\u5ea6<\/li>\n<li><code>calculateTriangleArea(base, height)<\/code> &#8211; \u8ba1\u7b97\u4e09\u89d2\u5f62\u9762\u79ef<\/li>\n<li><code>isEven(number)<\/code> &#8211; \u5224\u65ad\u6570\u5b57\u662f\u5426\u4e3a\u5076\u6570<\/li>\n<\/ol>\n<h3>\u7ec3\u4e60 2\uff1a\u6570\u7ec4\u5904\u7406\u51fd\u6570<\/h3>\n<p>\u521b\u5efa\u4ee5\u4e0b\u51fd\u6570\uff1a<\/p>\n<ol>\n<li><code>findMax(numbers)<\/code> &#8211; \u627e\u51fa\u6570\u7ec4\u6700\u5927\u503c<\/li>\n<li><code>filterPositive(numbers)<\/code> &#8211; \u8fc7\u6ee4\u51fa\u6b63\u6570<\/li>\n<li><code>reverseArray(arr)<\/code> &#8211; \u53cd\u8f6c\u6570\u7ec4\uff08\u4e0d\u4f7f\u7528 reverse()\uff09<\/li>\n<\/ol>\n<h3>\u7ec3\u4e60 3\uff1a\u5b57\u7b26\u4e32\u5904\u7406\u51fd\u6570<\/h3>\n<p>\u521b\u5efa\u4ee5\u4e0b\u51fd\u6570\uff1a<\/p>\n<ol>\n<li><code>capitalize(str)<\/code> &#8211; \u9996\u5b57\u6bcd\u5927\u5199<\/li>\n<li><code>truncate(str, length)<\/code> &#8211; \u622a\u65ad\u5b57\u7b26\u4e32\u5e76\u6dfb\u52a0 &quot;&#8230;&quot;<\/li>\n<li><code>countWords(str)<\/code> &#8211; \u7edf\u8ba1\u5355\u8bcd\u6570\u91cf<\/li>\n<\/ol>\n<h2>\ud83c\udf93 \u4eca\u65e5\u6311\u6218<\/h2>\n<p><strong>\u9879\u76ee\uff1a\u7b80\u6613\u8ba1\u7b97\u5668<\/strong><\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u7f51\u9875\u8ba1\u7b97\u5668\uff0c\u5b9e\u73b0\u4ee5\u4e0b\u529f\u80fd\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u57fa\u672c\u8fd0\u7b97<\/strong><\/p>\n<ul>\n<li>\u52a0\u6cd5\uff1a<code>add(a, b)<\/code><\/li>\n<li>\u51cf\u6cd5\uff1a<code>subtract(a, b)<\/code><\/li>\n<li>\u4e58\u6cd5\uff1a<code>multiply(a, b)<\/code><\/li>\n<li>\u9664\u6cd5\uff1a<code>divide(a, b)<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u9ad8\u7ea7\u8fd0\u7b97<\/strong><\/p>\n<ul>\n<li>\u5e42\u8fd0\u7b97\uff1a<code>power(base, exponent)<\/code><\/li>\n<li>\u5e73\u65b9\u6839\uff1a<code>sqrt(number)<\/code><\/li>\n<li>\u53d6\u4f59\uff1a<code>modulo(a, b)<\/code><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8f85\u52a9\u51fd\u6570<\/strong><\/p>\n<ul>\n<li>\u8f93\u5165\u9a8c\u8bc1\uff1a<code>validateInput(value)<\/code><\/li>\n<li>\u683c\u5f0f\u5316\u7ed3\u679c\uff1a<code>formatResult(number)<\/code><\/li>\n<li>\u9519\u8bef\u5904\u7406\uff1a\u5904\u7406\u9664\u96f6\u9519\u8bef<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>UI \u754c\u9762<\/strong><\/p>\n<ul>\n<li>\u521b\u5efa\u6309\u94ae\u548c\u663e\u793a\u533a\u57df<\/li>\n<li>\u7ed1\u5b9a\u70b9\u51fb\u4e8b\u4ef6<\/li>\n<li>\u663e\u793a\u8ba1\u7b97\u7ed3\u679c<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\u63d0\u793a<\/strong>\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u51fd\u6570\u5c01\u88c5\u6bcf\u4e2a\u8fd0\u7b97<\/li>\n<li>\u4f7f\u7528\u5bf9\u8c61\u5b58\u50a8\u8ba1\u7b97\u5386\u53f2<\/li>\n<li>\u4f7f\u7528\u56de\u8c03\u51fd\u6570\u5904\u7406\u6309\u94ae\u70b9\u51fb<\/li>\n<\/ul>\n<h2>\ud83d\udca1 \u6700\u4f73\u5b9e\u8df5<\/h2>\n<h3>1. \u5355\u4e00\u804c\u8d23\u539f\u5219<\/h3>\n<p>\u6bcf\u4e2a\u51fd\u6570\u53ea\u505a\u4e00\u4ef6\u4e8b\uff0c\u505a\u597d\u4e00\u4ef6\u4e8b\u3002<\/p>\n<h3>2. \u51fd\u6570\u547d\u540d<\/h3>\n<ul>\n<li>\u4f7f\u7528\u52a8\u8bcd\u5f00\u5934\uff1a<code>getUser()<\/code>, <code>calculateTotal()<\/code><\/li>\n<li>\u547d\u540d\u8981\u6e05\u6670\uff1a<code>x<\/code> \u2192 <code>userData<\/code>, <code>temp<\/code> \u2192 <code>temperature<\/code><\/li>\n<\/ul>\n<h3>3. \u53c2\u6570\u6570\u91cf<\/h3>\n<ul>\n<li>\u6700\u597d\u4e0d\u8d85\u8fc7 3-4 \u4e2a\u53c2\u6570<\/li>\n<li>\u53c2\u6570\u8fc7\u591a\u65f6\u4f7f\u7528\u5bf9\u8c61<\/li>\n<\/ul>\n<h3>4. \u7eaf\u51fd\u6570\u4f18\u5148<\/h3>\n<p>\u7eaf\u51fd\u6570\uff1a\u76f8\u540c\u8f93\u5165\u603b\u662f\u5f97\u5230\u76f8\u540c\u8f93\u51fa\uff0c\u65e0\u526f\u4f5c\u7528\u3002<\/p>\n<pre><code class=\"language-javascript\">\/\/ \u2705 \u7eaf\u51fd\u6570\nfunction add(a, b) {\n    return a + b;\n}\n\n\/\/ \u274c \u975e\u7eaf\u51fd\u6570\uff08\u6709\u526f\u4f5c\u7528\uff09\nfunction addAndLog(a, b) {\n    const result = a + b;\n    console.log(result);  \/\/ \u526f\u4f5c\u7528\n    return result;\n}\n<\/code><\/pre>\n<h2>\ud83d\udcda \u77e5\u8bc6\u62d3\u5c55<\/h2>\n<h3>\u9ad8\u9636\u51fd\u6570<\/h3>\n<p>\u9ad8\u9636\u51fd\u6570\u662f\u63a5\u6536\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\u6216\u8fd4\u56de\u51fd\u6570\u7684\u51fd\u6570\u3002<\/p>\n<pre><code class=\"language-javascript\">\/\/ \u63a5\u6536\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\nfunction calculate(operation, a, b) {\n    return operation(a, b);\n}\n\ncalculate((x, y) =&gt; x + y, 2, 3);  \/\/ 5\ncalculate((x, y) =&gt; x * y, 2, 3);  \/\/ 6\n\n\/\/ \u8fd4\u56de\u51fd\u6570\nfunction createMultiplier(multiplier) {\n    return function(x) {\n        return x * multiplier;\n    };\n}\n\nconst double = createMultiplier(2);\nconst triple = createMultiplier(3);\n\ndouble(5);  \/\/ 10\ntriple(5);  \/\/ 15\n<\/code><\/pre>\n<h3>\u9012\u5f52\u51fd\u6570<\/h3>\n<p>\u51fd\u6570\u8c03\u7528\u81ea\u8eab\u3002<\/p>\n<pre><code class=\"language-javascript\">\/\/ \u8ba1\u7b97\u9636\u4e58\nfunction factorial(n) {\n    if (n &lt;= 1) return 1;  \/\/ \u57fa\u51c6\u60c5\u51b5\n    return n * factorial(n - 1);  \/\/ \u9012\u5f52\u8c03\u7528\n}\n\nfactorial(5);  \/\/ 120\n<\/code><\/pre>\n<hr>\n<p><strong>\u5b66\u4e60\u65f6\u95f4<\/strong>: 2026-03-07 13:05<br \/>\n<strong>\u96be\u5ea6<\/strong>: \u2b50\u2b50\u2b50\u2606\u2606<br \/>\n<strong>\u9884\u8ba1\u7528\u65f6<\/strong>: 2-3 \u5c0f\u65f6<br \/>\n<strong>\u5173\u952e\u8bcd<\/strong>: \u51fd\u6570, \u53c2\u6570, \u8fd4\u56de\u503c, \u4f5c\u7528\u57df, \u56de\u8c03\u51fd\u6570, \u7bad\u5934\u51fd\u6570<br \/>\n<strong>\u76f8\u5173\u6807\u7b7e<\/strong>: #04-\u51fd\u6570<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Day 5: \u51fd\u6570\u5165\u95e8 \ud83c\udfaf \u5b66\u4e60\u76ee\u6807 \u7406\u89e3\u51fd\u6570\u7684\u6982\u5ff5\u548c\u4f5c\u7528 \u638c\u63e1\u51fd\u6570\u7684\u58f0\u660e\u3001\u8c03\u7528\u548c\u53c2\u6570\u4f20\u9012 \u5b66\u4f1a\u4f7f\u7528\u8fd4\u56de\u503c\u548c\u4f5c &#8230; <a title=\"Day-5-\u51fd\u6570\u5165\u95e8\" class=\"read-more\" href=\"https:\/\/www.resilence.cn\/?p=227\" aria-label=\"\u7ee7\u7eed\u9605\u8bfbDay-5-\u51fd\u6570\u5165\u95e8\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-227","post","type-post","status-publish","format-standard","hentry","category-studycoding"],"_links":{"self":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts\/227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=227"}],"version-history":[{"count":1,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":228,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=\/wp\/v2\/posts\/227\/revisions\/228"}],"wp:attachment":[{"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.resilence.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}