{"id":4936,"date":"2023-01-05T11:22:13","date_gmt":"2023-01-05T03:22:13","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=4936"},"modified":"2023-01-05T11:22:13","modified_gmt":"2023-01-05T03:22:13","slug":"%e4%ba%86%e8%a7%a3typescript%e5%85%a7%e7%bd%ae%e5%b0%8d%e8%b1%a1%e7%9a%84%e5%8a%9f%e8%83%bd%e8%88%87%e5%84%aa%e5%8b%a2","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e4%ba%86%e8%a7%a3typescript%e5%85%a7%e7%bd%ae%e5%b0%8d%e8%b1%a1%e7%9a%84%e5%8a%9f%e8%83%bd%e8%88%87%e5%84%aa%e5%8b%a2\/","title":{"rendered":"\u4e86\u89e3TypeScript\u5167\u7f6e\u5c0d\u8c61\u7684\u529f\u80fd\u8207\u512a\u52e2"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, Built-in Objects\"><\/p>\n<h1>TypeScript \u5167\u7f6e\u5c0d\u8c61(Built-in Objects)<\/h1>\n<p>TypeScript \u662f\u4e00\u7a2e JavaScript \u7684\u8d85\u96c6\uff0c\u5b83\u64c1\u6709 JavaScript \u7684\u6240\u6709\u7279\u6027\uff0c\u4e26\u4e14\u64f4\u5145\u4e86\u4e00\u4e9b\u65b0\u7684\u7279\u6027\uff0c\u5176\u4e2d\u5305\u62ec\u5167\u7f6e\u5c0d\u8c61(Built-in Objects)\u3002TypeScript \u5167\u7f6e\u5c0d\u8c61\u662f\u6307 TypeScript \u63d0\u4f9b\u7684\u4e00\u4e9b\u7279\u6b8a\u5c0d\u8c61\uff0c\u5b83\u5011\u53ef\u4ee5\u7528\u4f86\u64cd\u4f5c JavaScript \u7684\u7279\u6027\uff0c\u4f8b\u5982\uff1a\u5b57\u4e32\u3001\u6578\u5b57\u3001\u9663\u5217\u3001\u7269\u4ef6\u7b49\u7b49\u3002<\/p>\n<h2>TypeScript \u5167\u7f6e\u5c0d\u8c61\u7684\u529f\u80fd<\/h2>\n<p>TypeScript \u5167\u7f6e\u5c0d\u8c61\u7684\u529f\u80fd\u53ef\u4ee5\u5206\u70ba\u4e09\u5927\u985e\uff1a<\/p>\n<ul>\n<li><strong>\u57fa\u672c\u529f\u80fd\uff1a<\/strong>TypeScript \u5167\u7f6e\u5c0d\u8c61\u63d0\u4f9b\u4e86\u4e00\u4e9b\u57fa\u672c\u7684\u529f\u80fd\uff0c\u4f8b\u5982\uff1a\u5b57\u4e32\u3001\u6578\u5b57\u3001\u9663\u5217\u3001\u7269\u4ef6\u7b49\u7b49\uff0c\u53ef\u4ee5\u7528\u4f86\u64cd\u4f5c JavaScript \u7684\u7279\u6027\u3002<\/li>\n<li><strong>\u9ad8\u7d1a\u529f\u80fd\uff1a<\/strong>TypeScript \u5167\u7f6e\u5c0d\u8c61\u63d0\u4f9b\u4e86\u4e00\u4e9b\u9ad8\u7d1a\u7684\u529f\u80fd\uff0c\u4f8b\u5982\uff1a\u6a21\u677f\u5b57\u4e32\u3001\u89e3\u69cb\u8ce6\u503c\u3001\u985e\u5225\u3001\u6a21\u7d44\u7b49\u7b49\uff0c\u53ef\u4ee5\u7528\u4f86\u64f4\u5145 JavaScript \u7684\u7279\u6027\u3002<\/li>\n<li><strong>\u7cfb\u7d71\u529f\u80fd\uff1a<\/strong>TypeScript \u5167\u7f6e\u5c0d\u8c61\u63d0\u4f9b\u4e86\u4e00\u4e9b\u7cfb\u7d71\u7684\u529f\u80fd\uff0c\u4f8b\u5982\uff1a\u932f\u8aa4\u8655\u7406\u3001\u8cc7\u6599\u8655\u7406\u3001\u6a94\u6848\u8655\u7406\u7b49\u7b49\uff0c\u53ef\u4ee5\u7528\u4f86\u64cd\u4f5c JavaScript \u7684\u7279\u6027\u3002<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h2>TypeScript \u5167\u7f6e\u5c0d\u8c61\u7684\u4f7f\u7528<\/h2>\n<p>TypeScript \u5167\u7f6e\u5c0d\u8c61\u7684\u4f7f\u7528\u65b9\u5f0f\u53ef\u4ee5\u5206\u70ba\u5169\u7a2e\uff1a<\/p>\n<ul>\n<li><strong>\u57fa\u672c\u4f7f\u7528\uff1a<\/strong>TypeScript \u5167\u7f6e\u5c0d\u8c61\u53ef\u4ee5\u7528\u4f86\u64cd\u4f5c JavaScript \u7684\u7279\u6027\uff0c\u4f8b\u5982\uff1a\u5b57\u4e32\u3001\u6578\u5b57\u3001\u9663\u5217\u3001\u7269\u4ef6\u7b49\u7b49\uff0c\u53ef\u4ee5\u7528\u4f86\u5be6\u73fe\u4e00\u4e9b\u57fa\u672c\u7684\u529f\u80fd\u3002<\/li>\n<li><strong>\u9ad8\u7d1a\u4f7f\u7528\uff1a<\/strong>TypeScript \u5167\u7f6e\u5c0d\u8c61\u53ef\u4ee5\u7528\u4f86\u64f4\u5145 JavaScript \u7684\u7279\u6027\uff0c\u4f8b\u5982\uff1a\u6a21\u677f\u5b57\u4e32\u3001\u89e3\u69cb\u8ce6\u503c\u3001\u985e\u5225\u3001\u6a21\u7d44\u7b49\u7b49\uff0c\u53ef\u4ee5\u7528\u4f86\u5be6\u73fe\u4e00\u4e9b\u9ad8\u7d1a\u7684\u529f\u80fd\u3002<\/li>\n<\/ul>\n<h2>\u7bc4\u4f8b\uff1a\u4f7f\u7528 TypeScript \u5167\u7f6e\u5c0d\u8c61<\/h2>\n<p>\u4e0b\u9762\u662f\u4e00\u500b\u4f7f\u7528 TypeScript \u5167\u7f6e\u5c0d\u8c61\u7684\u7bc4\u4f8b\uff1a<\/p>\n<pre class=\"brush: typescript\">\n\/\/ \u5b9a\u7fa9\u4e00\u500b\u9663\u5217\nlet arr = [1, 2, 3];\n\n\/\/ \u4f7f\u7528 for...of \u8fed\u4ee3\u9663\u5217\nfor (let item of arr) {\n    console.log(item);\n}\n\n\/\/ \u4f7f\u7528\u6a21\u677f\u5b57\u4e32\nlet str = `Hello, ${arr[0]}`;\nconsole.log(str);\n\n\/\/ \u4f7f\u7528\u89e3\u69cb\u8ce6\u503c\nlet [a, b, c] = arr;\nconsole.log(a, b, c);\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u4f7f\u7528\u4e86 TypeScript \u5167\u7f6e\u5c0d\u8c61\u7684 for&#8230;of \u8fed\u4ee3\u9663\u5217\u3001\u6a21\u677f\u5b57\u4e32\u3001\u89e3\u69cb\u8ce6\u503c\u7b49\u529f\u80fd\uff0c\u53ef\u4ee5\u770b\u5230 TypeScript \u5167\u7f6e\u5c0d\u8c61\u7684\u529f\u80fd\u975e\u5e38\u5f37\u5927\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u5347\u958b\u767c\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981:TypeScript\u5167\u7f6e\u5c0d\u8c61\u662f\u4e00\u7a2e\u5f37\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5e6b\u52a9\u958b\u767c\u8005\u66f4\u8f15\u9b06\u5730\u5275\u5efa\u548c\u7ba1\u7406\u61c9\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c07\u4ecb\u7d39TypeScript\u5167\u7f6e\u5c0d\u8c61\u7684\u529f\u80fd\uff0c\u4ee5\u53ca\u5b83\u5011\u5982\u4f55\u5e6b\u52a9\u958b\u767c\u8005\u66f4\u6709\u6548\u5730\u958b\u767c\u61c9\u7528\u7a0b\u5e8f\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-4936","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-1hC","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4936","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=4936"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4936\/revisions"}],"predecessor-version":[{"id":4937,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4936\/revisions\/4937"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=4936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=4936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=4936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}