{"id":5156,"date":"2023-01-05T12:04:45","date_gmt":"2023-01-05T04:04:45","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5156"},"modified":"2023-01-05T12:04:45","modified_gmt":"2023-01-05T04:04:45","slug":"%e4%ba%86%e8%a7%a3typescript%e5%ad%97%e4%b8%b2%e7%9a%84%e5%88%aa%e9%99%a4%e5%85%a9%e9%82%8a%e7%a9%ba%e6%a0%bctrim%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e4%ba%86%e8%a7%a3typescript%e5%ad%97%e4%b8%b2%e7%9a%84%e5%88%aa%e9%99%a4%e5%85%a9%e9%82%8a%e7%a9%ba%e6%a0%bctrim%e5%8a%9f%e8%83%bd\/","title":{"rendered":"\u4e86\u89e3TypeScript\u5b57\u4e32\u7684\u522a\u9664\u5169\u908a\u7a7a\u683c(trim)\u529f\u80fd"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, \u5b57\u4e32, \u522a\u9664\u5169\u908a\u7a7a\u683c, trim\"><\/p>\n<h1>TypeScript \u5b57\u4e32\u7684\u522a\u9664\u5169\u908a\u7a7a\u683c(trim)<\/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\u53ef\u4ee5\u8f15\u9b06\u5730\u5c0d\u5b57\u4e32\u9032\u884c\u522a\u9664\u5169\u908a\u7a7a\u683c\u7684\u64cd\u4f5c\uff0c\u4e5f\u5c31\u662f\u6240\u8b02\u7684 trim \u64cd\u4f5c\u3002<\/p>\n<p>\u5728 TypeScript \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>.trim()<\/code> \u65b9\u6cd5\u4f86\u5c0d\u5b57\u4e32\u9032\u884c\u522a\u9664\u5169\u908a\u7a7a\u683c\u7684\u64cd\u4f5c\uff0c\u5b83\u6703\u5c07\u5b57\u4e32\u4e2d\u7684\u5169\u908a\u7a7a\u683c\u522a\u9664\uff0c\u4e26\u4e14\u56de\u50b3\u4e00\u500b\u65b0\u7684\u5b57\u4e32\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u500b\u7c21\u55ae\u7684\u7bc4\u4f8b\uff0c\u53ef\u4ee5\u770b\u5230\u5728\u4f7f\u7528 <code>.trim()<\/code> \u65b9\u6cd5\u5f8c\uff0c\u5b57\u4e32\u4e2d\u7684\u5169\u908a\u7a7a\u683c\u5c31\u88ab\u522a\u9664\u4e86\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet str = \"  Hello World  \";\nlet newStr = str.trim();\n\nconsole.log(newStr); \/\/ \"Hello World\"\n<\/pre>\n<p>\u53e6\u5916\uff0c<code>.trim()<\/code> \u65b9\u6cd5\u4e5f\u53ef\u4ee5\u63a5\u53d7\u4e00\u500b\u53c3\u6578\uff0c\u7528\u4f86\u6307\u5b9a\u8981\u522a\u9664\u7684\u5b57\u5143\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet str = \"  Hello World  \";\nlet newStr = str.trim(\"H\");\n\nconsole.log(newStr); \/\/ \"ello World  \"\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u6307\u5b9a\u8981\u522a\u9664\u5b57\u4e32\u4e2d\u7684 <code>H<\/code> \u5b57\u5143\uff0c\u56e0\u6b64\u5b57\u4e32\u4e2d\u7684\u5169\u500b <code>H<\/code> \u5c31\u88ab\u522a\u9664\u4e86\uff0c\u800c\u5176\u4ed6\u7684\u7a7a\u683c\u5247\u4fdd\u7559\u4e86\u3002<\/p>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0cTypeScript \u4e2d\u7684 <code>.trim()<\/code> \u65b9\u6cd5\u53ef\u4ee5\u8f15\u9b06\u5730\u5c0d\u5b57\u4e32\u9032\u884c\u522a\u9664\u5169\u908a\u7a7a\u683c\u7684\u64cd\u4f5c\uff0c\u4e26\u4e14\u53ef\u4ee5\u6307\u5b9a\u8981\u522a\u9664\u7684\u5b57\u5143\uff0c\u4f7f\u7528\u8d77\u4f86\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<p><!--more--><\/p>\n<h2>TypeScript \u5b57\u4e32\u7684\u522a\u9664\u5169\u908a\u7a7a\u683c(trim)\u7684\u512a\u9ede<\/h2>\n<p>TypeScript \u4e2d\u7684 <code>.trim()<\/code> \u65b9\u6cd5\u53ef\u4ee5\u8b93\u6211\u5011\u8f15\u9b06\u5730\u5c0d\u5b57\u4e32\u9032\u884c\u522a\u9664\u5169\u908a\u7a7a\u683c\u7684\u64cd\u4f5c\uff0c\u5b83\u7684\u512a\u9ede\u6709\uff1a<\/p>\n<ul>\n<li><strong>\u7c21\u55ae\u6613\u7528\uff1a<\/strong>\u4f7f\u7528 <code>.trim()<\/code> \u65b9\u6cd5\u53ea\u9700\u8981\u4e00\u884c\u7a0b\u5f0f\u78bc\uff0c\u5c31\u53ef\u4ee5\u5c0d\u5b57\u4e32\u9032\u884c\u522a\u9664\u5169\u908a\u7a7a\u683c\u7684\u64cd\u4f5c\uff0c\u975e\u5e38\u65b9\u4fbf\u3002<\/li>\n<li><strong>\u53ef\u6307\u5b9a\u5b57\u5143\uff1a<\/strong> <code>.trim()<\/code> \u65b9\u6cd5\u53ef\u4ee5\u63a5\u53d7\u4e00\u500b\u53c3\u6578\uff0c\u7528\u4f86\u6307\u5b9a\u8981\u522a\u9664\u7684\u5b57\u5143\uff0c\u53ef\u4ee5\u8b93\u6211\u5011\u66f4\u52a0\u7cbe\u78ba\u5730\u63a7\u5236\u522a\u9664\u7684\u7bc4\u570d\u3002<\/li>\n<\/ul>\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\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f\u53ef\u4ee5\u8f15\u9b06\u5730\u5c0d\u5b57\u4e32\u9032\u884c\u522a\u9664\u5169\u908a\u7a7a\u683c\u7684\u64cd\u4f5c\uff0c\u4e5f\u5c31\u662f\u6240\u8b02\u7684 trim \u64cd\u4f5c\u3002\u4f7f\u7528 <code>.trim()<\/code> \u65b9\u6cd5\u53ea\u9700\u8981\u4e00\u884c\u7a0b\u5f0f\u78bc\uff0c\u5c31\u53ef\u4ee5\u5c0d\u5b57\u4e32\u9032\u884c\u522a\u9664\u5169\u908a\u7a7a\u683c\u7684\u64cd\u4f5c\uff0c\u4e26\u4e14\u53ef\u4ee5\u6307\u5b9a\u8981\u522a\u9664\u7684\u5b57\u5143\uff0c\u4f7f\u7528\u8d77\u4f86\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3TypeScript\u5b57\u4e32\u7684\u522a\u9664\u5169\u908a\u7a7a\u683c(trim)\u529f\u80fd\uff0c\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528trim()\u51fd\u6578\u5c07\u5b57\u4e32\u5169\u908a\u7684\u7a7a\u683c\u522a\u9664\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528trimStart()\u548ctrimEnd()\u51fd\u6578\u5c07\u5b57\u4e32\u982d\u5c3e\u7684\u7a7a\u683c\u522a\u9664\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-5156","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-1la","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5156","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=5156"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5156\/revisions"}],"predecessor-version":[{"id":5157,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5156\/revisions\/5157"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}