{"id":5520,"date":"2023-01-05T12:54:43","date_gmt":"2023-01-05T04:54:43","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5520"},"modified":"2023-01-05T12:54:43","modified_gmt":"2023-01-05T04:54:43","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8typescript%e9%99%a3%e5%88%97%e7%9a%84%e6%b1%82%e7%a7%afproduct","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8typescript%e9%99%a3%e5%88%97%e7%9a%84%e6%b1%82%e7%a7%afproduct\/","title":{"rendered":"\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528TypeScript\u9663\u5217\u7684\u6c42\u79ef(product)"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, \u9663\u5217, \u6c42\u79ef, product\"><\/p>\n<h1>TypeScript \u9663\u5217\u7684\u6c42\u79ef(product)<\/h1>\n<p>TypeScript \u662f\u4e00\u7a2e JavaScript \u7684\u8d85\u96c6\uff0c\u5b83\u64c1\u6709\u66f4\u591a\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u958b\u767c\u51fa\u66f4\u512a\u8cea\u7684\u7a0b\u5f0f\u78bc\u3002\u5728 TypeScript \u4e2d\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528\u9663\u5217\u7684\u6c42\u79ef(product)\u529f\u80fd\uff0c\u5c0d\u9663\u5217\u4e2d\u7684\u5143\u7d20\u9032\u884c\u4e58\u7a4d\u904b\u7b97\uff0c\u4ee5\u53d6\u5f97\u9663\u5217\u4e2d\u6240\u6709\u5143\u7d20\u7684\u4e58\u7a4d\u3002<\/p>\n<h2>\u4f7f\u7528 TypeScript \u9663\u5217\u7684\u6c42\u79ef(product)<\/h2>\n<p>\u4f7f\u7528 TypeScript \u9663\u5217\u7684\u6c42\u79ef(product)\u529f\u80fd\uff0c\u53ef\u4ee5\u8f15\u9b06\u5730\u5c0d\u9663\u5217\u4e2d\u7684\u5143\u7d20\u9032\u884c\u4e58\u7a4d\u904b\u7b97\uff0c\u4ee5\u53d6\u5f97\u9663\u5217\u4e2d\u6240\u6709\u5143\u7d20\u7684\u4e58\u7a4d\u3002<\/p>\n<h3>\u7bc4\u4f8b<\/h3>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528 TypeScript \u9663\u5217\u7684\u6c42\u79ef(product)\u529f\u80fd\u7684\u7bc4\u4f8b\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet numbers = [1, 2, 3, 4, 5];\nlet product = numbers.reduce((acc, curr) => acc * curr);\nconsole.log(product); \/\/ 120\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u5b9a\u7fa9\u4e86\u4e00\u500b\u540d\u70ba numbers \u7684\u9663\u5217\uff0c\u5176\u4e2d\u5305\u542b\u4e86 1 \u5230 5 \u7684\u6578\u5b57\u3002\u7136\u5f8c\uff0c\u6211\u5011\u4f7f\u7528 reduce() \u65b9\u6cd5\u5c0d numbers \u9663\u5217\u4e2d\u7684\u5143\u7d20\u9032\u884c\u4e58\u7a4d\u904b\u7b97\uff0c\u4e26\u5c07\u7d50\u679c\u5b58\u5165 product \u8b8a\u6578\u4e2d\u3002\u6700\u5f8c\uff0c\u6211\u5011\u4f7f\u7528 console.log() \u65b9\u6cd5\u5c07 product \u8b8a\u6578\u7684\u503c\u8f38\u51fa\u5230\u63a7\u5236\u53f0\uff0c\u7d50\u679c\u70ba 120\u3002<\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>TypeScript \u662f\u4e00\u7a2e JavaScript \u7684\u8d85\u96c6\uff0c\u5b83\u64c1\u6709\u66f4\u591a\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u958b\u767c\u51fa\u66f4\u512a\u8cea\u7684\u7a0b\u5f0f\u78bc\u3002\u5728 TypeScript \u4e2d\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528\u9663\u5217\u7684\u6c42\u79ef(product)\u529f\u80fd\uff0c\u5c0d\u9663\u5217\u4e2d\u7684\u5143\u7d20\u9032\u884c\u4e58\u7a4d\u904b\u7b97\uff0c\u4ee5\u53d6\u5f97\u9663\u5217\u4e2d\u6240\u6709\u5143\u7d20\u7684\u4e58\u7a4d\u3002<!--more-->\u4f7f\u7528 TypeScript \u9663\u5217\u7684\u6c42\u79ef(product)\u529f\u80fd\uff0c\u53ef\u4ee5\u8f15\u9b06\u5730\u5c0d\u9663\u5217\u4e2d\u7684\u5143\u7d20\u9032\u884c\u4e58\u7a4d\u904b\u7b97\uff0c\u4ee5\u53d6\u5f97\u9663\u5217\u4e2d\u6240\u6709\u5143\u7d20\u7684\u4e58\u7a4d\u3002\u4ee5\u4e0a\u5c31\u662f TypeScript \u9663\u5217\u7684\u6c42\u79ef(product)\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u5e0c\u671b\u5c0d\u5927\u5bb6\u6709\u6240\u5e6b\u52a9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528TypeScript\u9663\u5217\u7684\u6c42\u79ef(product)\u51fd\u6578\uff0c\u8a72\u51fd\u6578\u53ef\u4ee5\u5c07\u9663\u5217\u4e2d\u7684\u6240\u6709\u5143\u7d20\u76f8\u4e58\uff0c\u4e26\u8fd4\u56de\u4e58\u7a4d\u7684\u7d50\u679c\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eTypeScript\u9663\u5217\u7684\u6c42\u79ef(product)\u51fd\u6578\u7684\u529f\u80fd\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u4f86\u89e3\u6c7a\u554f\u984c\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-5520","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-1r2","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5520","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=5520"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5520\/revisions"}],"predecessor-version":[{"id":5521,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5520\/revisions\/5521"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}