{"id":5168,"date":"2023-01-05T12:06:39","date_gmt":"2023-01-05T04:06:39","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5168"},"modified":"2023-01-05T12:06:39","modified_gmt":"2023-01-05T04:06:39","slug":"%e5%ad%b8%e7%bf%92typescript%e4%b8%ad%e7%9a%84%e7%ae%ad%e9%a0%ad%e5%87%bd%e6%95%b8%ef%bc%9a%e6%9b%b4%e5%bf%ab%e6%9b%b4%e7%b0%a1%e5%96%ae%e7%9a%84%e9%96%8b%e7%99%bc%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e5%ad%b8%e7%bf%92typescript%e4%b8%ad%e7%9a%84%e7%ae%ad%e9%a0%ad%e5%87%bd%e6%95%b8%ef%bc%9a%e6%9b%b4%e5%bf%ab%e6%9b%b4%e7%b0%a1%e5%96%ae%e7%9a%84%e9%96%8b%e7%99%bc%e6%96%b9%e5%bc%8f\/","title":{"rendered":"\u5b78\u7fd2TypeScript\u4e2d\u7684\u7bad\u982d\u51fd\u6578\uff1a\u66f4\u5feb\u66f4\u7c21\u55ae\u7684\u958b\u767c\u65b9\u5f0f"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, Functions, \u7bad\u5934\u51fd\u6570\"><\/p>\n<h1>TypeScript \u51fd\u6570(functions)\u7684\u7bad\u5934\u51fd\u6570<\/h1>\n<p>TypeScript \u662f\u4e00\u7a2e JavaScript \u7684\u8d85\u96c6\uff0c\u5b83\u64c1\u6709\u66f4\u591a\u7684\u529f\u80fd\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f\u7bad\u5934\u51fd\u6578\u3002\u7bad\u5934\u51fd\u6578\u662f\u4e00\u7a2e\u66f4\u7c21\u6f54\u7684\u51fd\u6578\u8868\u9054\u5f0f\uff0c\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u64b0\u5beb\u51fd\u6578\uff0c\u4e26\u4e14\u66f4\u5bb9\u6613\u7406\u89e3\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u7bad\u5934\u51fd\u6578\u7684\u8a9e\u6cd5\u975e\u5e38\u7c21\u55ae\uff0c\u5b83\u7684\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: typescript\">\n(param1, param2, \u2026, paramN) => { statements } \n<\/pre>\n<p>\u7bad\u5934\u51fd\u6578\u53ef\u4ee5\u63a5\u53d7\u4e00\u500b\u6216\u591a\u500b\u53c3\u6578\uff0c\u4e26\u4e14\u53ef\u4ee5\u8fd4\u56de\u4e00\u500b\u503c\u3002\u5b83\u7684\u8a9e\u6cd5\u6bd4\u50b3\u7d71\u7684\u51fd\u6578\u66f4\u7c21\u6f54\uff0c\u4e26\u4e14\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u64b0\u5beb\u51fd\u6578\u3002<\/p>\n<p>\u8209\u500b\u4f8b\u5b50\uff0c\u5047\u8a2d\u6211\u5011\u60f3\u8981\u5beb\u4e00\u500b\u51fd\u6578\uff0c\u7528\u65bc\u8a08\u7b97\u5169\u500b\u6578\u5b57\u7684\u548c\uff0c\u6211\u5011\u53ef\u4ee5\u4f7f\u7528\u7bad\u5934\u51fd\u6578\u4f86\u5beb\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet add = (a, b) => a + b;\n<\/pre>\n<p>\u9019\u6a23\uff0c\u6211\u5011\u5c31\u53ef\u4ee5\u4f7f\u7528\u9019\u500b\u51fd\u6578\u4f86\u8a08\u7b97\u5169\u500b\u6578\u5b57\u7684\u548c\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet result = add(1, 2);\nconsole.log(result); \/\/ 3\n<\/pre>\n<p>\u7bad\u5934\u51fd\u6578\u9084\u53ef\u4ee5\u7528\u65bc\u66f4\u8907\u96dc\u7684\u51fd\u6578\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet multiply = (a, b) => {\n  let result = a * b;\n  return result;\n};\n\nlet result = multiply(2, 3);\nconsole.log(result); \/\/ 6\n<\/pre>\n<p>\u7bad\u5934\u51fd\u6578\u53ef\u4ee5\u8b93\u6211\u5011\u66f4\u5bb9\u6613\u5730\u64b0\u5beb\u51fd\u6578\uff0c\u4e26\u4e14\u66f4\u5bb9\u6613\u7406\u89e3\u3002\u5b83\u7684\u8a9e\u6cd5\u6bd4\u50b3\u7d71\u7684\u51fd\u6578\u66f4\u7c21\u6f54\uff0c\u4e26\u4e14\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u64b0\u5beb\u51fd\u6578\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1aTypeScript\u4e2d\u7684\u7bad\u982d\u51fd\u6578\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5feb\u66f4\u7c21\u55ae\u7684\u5b8c\u6210\u7a0b\u5f0f\u78bc\uff0c\u5b83\u53ef\u4ee5\u6e1b\u5c11\u958b\u767c\u6642\u9593\uff0c\u4e26\u4e14\u63d0\u9ad8\u7a0b\u5f0f\u78bc\u7684\u53ef\u8b80\u6027\u3002\u672c\u6587\u5c07\u4ecb\u7d39TypeScript\u4e2d\u7684\u7bad\u982d\u51fd\u6578\u7684\u57fa\u672c\u6982\u5ff5\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u4f86\u63d0\u9ad8\u958b\u767c\u6548\u7387\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[187],"tags":[186],"class_list":["post-5168","post","type-post","status-publish","format-standard","hentry","category-typescript","tag-typescript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1lm","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=5168"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5168\/revisions"}],"predecessor-version":[{"id":5169,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5168\/revisions\/5169"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}