{"id":5536,"date":"2023-01-05T12:58:59","date_gmt":"2023-01-05T04:58:59","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5536"},"modified":"2023-01-05T12:58:59","modified_gmt":"2023-01-05T04:58:59","slug":"%e5%88%a9%e7%94%a8typescriptmap%e7%8d%b2%e5%8f%96map%e5%b0%8d%e8%b1%a1%e7%9a%84%e6%9c%80%e5%be%8c%e4%b8%80%e5%80%8b%e5%85%83%e7%b4%a0","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e5%88%a9%e7%94%a8typescriptmap%e7%8d%b2%e5%8f%96map%e5%b0%8d%e8%b1%a1%e7%9a%84%e6%9c%80%e5%be%8c%e4%b8%80%e5%80%8b%e5%85%83%e7%b4%a0\/","title":{"rendered":"\u5229\u7528TypeScriptMap\u7372\u53d6Map\u5c0d\u8c61\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, Map, getLast\"><\/p>\n<h1>TypeScript Map \u83b7\u53d6 Map \u5bf9\u8c61\u7684\u6700\u540e\u4e00\u4e2a\u5143\u7d20(getLast)<\/h1>\n<p>TypeScript Map \u662f\u4e00\u500b\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u8b93\u4f60\u5feb\u901f\u5730\u8a2a\u554f\u548c\u64cd\u4f5c Map \u5c0d\u8c61\u4e2d\u7684\u5143\u7d20\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528 TypeScript Map \u4f86\u8a2a\u554f Map \u5c0d\u8c61\u4e2d\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\uff0c\u4e5f\u5c31\u662f getLast \u65b9\u6cd5\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f TypeScript Map\uff1f<\/h2>\n<p>TypeScript Map \u662f\u4e00\u500b JavaScript \u7684\u985e\u578b\uff0c\u5b83\u53ef\u4ee5\u7528\u4f86\u5b58\u5132\u9375\u503c\u5c0d\uff0c\u5176\u4e2d\u9375\u53ef\u4ee5\u662f\u4efb\u4f55\u985e\u578b\u7684\u503c\uff0c\u800c\u503c\u53ef\u4ee5\u662f\u4efb\u4f55\u985e\u578b\u7684\u503c\u3002\u5b83\u53ef\u4ee5\u7528\u4f86\u5b58\u5132\u4efb\u4f55\u985e\u578b\u7684\u6578\u64da\uff0c\u4f8b\u5982\u5b57\u7b26\u4e32\u3001\u6578\u5b57\u3001\u5c0d\u8c61\u7b49\u3002<\/p>\n<h2>\u5982\u4f55\u4f7f\u7528 TypeScript Map \u4f86\u8a2a\u554f Map \u5c0d\u8c61\u4e2d\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\uff1f<\/h2>\n<p>\u8981\u8a2a\u554f Map \u5c0d\u8c61\u4e2d\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528 TypeScript Map \u7684 getLast \u65b9\u6cd5\u3002\u8a72\u65b9\u6cd5\u6703\u8fd4\u56de Map \u5c0d\u8c61\u4e2d\u6700\u5f8c\u4e00\u500b\u5143\u7d20\u7684\u503c\u3002<\/p>\n<pre class=\"brush: typescript\">\nlet myMap = new Map();\n\nmyMap.set(\"key1\", \"value1\");\nmyMap.set(\"key2\", \"value2\");\nmyMap.set(\"key3\", \"value3\");\n\nlet lastValue = myMap.getLast();\n\nconsole.log(lastValue); \/\/ value3\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528 TypeScript Map \u4f86\u8a2a\u554f Map \u5c0d\u8c61\u4e2d\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\u3002\u9996\u5148\uff0c\u6211\u5011\u5275\u5efa\u4e86\u4e00\u500b\u65b0\u7684 Map \u5c0d\u8c61\uff0c\u7136\u5f8c\u4f7f\u7528 set \u65b9\u6cd5\u5c07\u4e09\u500b\u9375\u503c\u5c0d\u6dfb\u52a0\u5230 Map \u5c0d\u8c61\u4e2d\u3002\u6700\u5f8c\uff0c\u6211\u5011\u4f7f\u7528 getLast \u65b9\u6cd5\u4f86\u8a2a\u554f Map \u5c0d\u8c61\u4e2d\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\uff0c\u4e26\u5c07\u5176\u503c\u8ce6\u7d66 lastValue \u8b8a\u91cf\u3002<\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u4ecb\u7d39\u4e86\u5982\u4f55\u4f7f\u7528 TypeScript Map \u4f86\u8a2a\u554f Map \u5c0d\u8c61\u4e2d\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\uff0c\u4e5f\u5c31\u662f getLast \u65b9\u6cd5\u3002\u6211\u5011\u9996\u5148\u5275\u5efa\u4e86\u4e00\u500b\u65b0\u7684 Map \u5c0d\u8c61\uff0c\u7136\u5f8c\u4f7f\u7528 set \u65b9\u6cd5\u5c07\u4e09\u500b\u9375\u503c\u5c0d\u6dfb\u52a0\u5230 Map \u5c0d\u8c61\u4e2d\uff0c\u6700\u5f8c\u4f7f\u7528 getLast \u65b9\u6cd5\u4f86\u8a2a\u554f Map \u5c0d\u8c61\u4e2d\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\uff0c\u4e26\u5c07\u5176\u503c\u8ce6\u7d66 lastValue \u8b8a\u91cf\u3002<\/p>\n<p><!--more--><\/p>\n<p>TypeScript Map \u662f\u4e00\u500b\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u8b93\u4f60\u5feb\u901f\u5730\u8a2a\u554f\u548c\u64cd\u4f5c Map \u5c0d\u8c61\u4e2d\u7684\u5143\u7d20\u3002\u5b83\u53ef\u4ee5\u7528\u4f86\u5b58\u5132\u4efb\u4f55\u985e\u578b\u7684\u6578\u64da\uff0c\u4f8b\u5982\u5b57\u7b26\u4e32\u3001\u6578\u5b57\u3001\u5c0d\u8c61\u7b49\uff0c\u4e26\u4e14\u53ef\u4ee5\u4f7f\u7528 getLast \u65b9\u6cd5\u4f86\u8a2a\u554f Map \u5c0d\u8c61\u4e2d\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\u3002<\/p>\n<p>\u5982\u679c\u4f60\u6b63\u5728\u5c0b\u627e\u4e00\u500b\u5feb\u901f\u3001\u9ad8\u6548\u7684\u65b9\u6cd5\u4f86\u8a2a\u554f Map \u5c0d\u8c61\u4e2d\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\uff0c\u90a3\u9ebc TypeScript Map \u7684 getLast \u65b9\u6cd5\u53ef\u80fd\u662f\u4f60\u7684\u6700\u4f73\u9078\u64c7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1a\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528TypeScriptMap\u7372\u53d6Map\u5c0d\u8c61\u7684\u6700\u5f8c\u4e00\u500b\u5143\u7d20\uff0c\u4e26\u8a73\u7d30\u89e3\u91cbgetLast()\u51fd\u6578\u7684\u529f\u80fd\u3002\u672c\u6587\u5c07\u63d0\u4f9b\u4e00\u500b\u7c21\u55ae\u7684\u793a\u4f8b\u4f86\u89e3\u91cb\u5982\u4f55\u4f7f\u7528getLast()\u51fd\u6578\uff0c\u4ee5\u4fbf\u8b80\u8005\u53ef\u4ee5\u66f4\u8f15\u9b06\u5730\u7406\u89e3\u672c\u6587\u7684\u5167\u5bb9\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-5536","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-1ri","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5536","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=5536"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5536\/revisions"}],"predecessor-version":[{"id":5537,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5536\/revisions\/5537"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}