{"id":5036,"date":"2023-01-05T11:42:28","date_gmt":"2023-01-05T03:42:28","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5036"},"modified":"2023-01-05T11:42:28","modified_gmt":"2023-01-05T03:42:28","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8typescript%e5%ad%97%e4%b8%b2%e7%9a%84%e6%b1%82ascii%e7%a2%bccharcodeat%e5%8a%9f%e8%83%bd","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%e5%ad%97%e4%b8%b2%e7%9a%84%e6%b1%82ascii%e7%a2%bccharcodeat%e5%8a%9f%e8%83%bd\/","title":{"rendered":"\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528TypeScript\u5b57\u4e32\u7684\u6c42ASCII\u78bc(charCodeAt)\u529f\u80fd"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, ASCII, charCodeAt\"><\/p>\n<h1>TypeScript \u5b57\u4e32\u7684\u6c42ASCII\u78bc(charCodeAt)<\/h1>\n<p>TypeScript \u662f\u4e00\u7a2e JavaScript \u7684\u8d85\u96c6\uff0c\u5b83\u64c1\u6709 JavaScript \u7684\u6240\u6709\u529f\u80fd\uff0c\u4e26\u4e14\u63d0\u4f9b\u4e86\u984d\u5916\u7684\u7279\u6027\uff0c\u4f8b\u5982\u985e\u578b\u6aa2\u67e5\u548c\u975c\u614b\u5206\u6790\u7b49\u3002\u5728 TypeScript \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 charCodeAt() \u65b9\u6cd5\u4f86\u6c42\u5f97\u5b57\u4e32\u4e2d\u6bcf\u500b\u5b57\u5143\u7684 ASCII \u78bc\u3002<\/p>\n<p><!--more--><\/p>\n<p>charCodeAt() \u65b9\u6cd5\u63a5\u53d7\u4e00\u500b\u53c3\u6578\uff0c\u5373\u8981\u6c42 ASCII \u78bc\u7684\u5b57\u5143\u7684\u7d22\u5f15\uff0c\u4e26\u8fd4\u56de\u8a72\u5b57\u5143\u7684 ASCII \u78bc\u3002\u4f8b\u5982\uff0c\u5047\u8a2d\u6709\u4e00\u500b\u5b57\u4e32 str\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u5b57\u5143 &#8216;A&#8217;\uff0c\u5247\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8a9e\u53e5\u4f86\u6c42\u5f97 &#8216;A&#8217; \u7684 ASCII \u78bc\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet str = 'A';\nlet asciiCode = str.charCodeAt(0);\nconsole.log(asciiCode); \/\/ 65\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u4f7f\u7528\u4e86 charCodeAt() \u65b9\u6cd5\u4f86\u6c42\u5f97\u5b57\u4e32 str \u4e2d\u7d22\u5f15\u70ba 0 \u7684\u5b57\u5143 &#8216;A&#8217; \u7684 ASCII \u78bc\uff0c\u4e26\u5c07\u7d50\u679c\u5b58\u5132\u5728\u8b8a\u6578 asciiCode \u4e2d\u3002<\/p>\n<p>\u6b64\u5916\uff0ccharCodeAt() \u65b9\u6cd5\u4e5f\u53ef\u4ee5\u7528\u65bc\u6c42\u5f97\u5b57\u4e32\u4e2d\u6bcf\u500b\u5b57\u5143\u7684 ASCII \u78bc\uff0c\u4f8b\u5982\uff0c\u5047\u8a2d\u6709\u4e00\u500b\u5b57\u4e32 str\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u5b57\u5143 &#8216;A&#8217;\u3001&#8217;B&#8217; \u548c &#8216;C&#8217;\uff0c\u5247\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8a9e\u53e5\u4f86\u6c42\u5f97\u6bcf\u500b\u5b57\u5143\u7684 ASCII \u78bc\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet str = 'ABC';\nlet asciiCodeA = str.charCodeAt(0);\nlet asciiCodeB = str.charCodeAt(1);\nlet asciiCodeC = str.charCodeAt(2);\nconsole.log(asciiCodeA); \/\/ 65\nconsole.log(asciiCodeB); \/\/ 66\nconsole.log(asciiCodeC); \/\/ 67\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u4e2d\uff0c\u6211\u5011\u4f7f\u7528\u4e86 charCodeAt() \u65b9\u6cd5\u4f86\u6c42\u5f97\u5b57\u4e32 str \u4e2d\u7d22\u5f15\u70ba 0\u30011 \u548c 2 \u7684\u5b57\u5143 &#8216;A&#8217;\u3001&#8217;B&#8217; \u548c &#8216;C&#8217; \u7684 ASCII \u78bc\uff0c\u4e26\u5c07\u7d50\u679c\u5206\u5225\u5b58\u5132\u5728\u8b8a\u6578 asciiCodeA\u3001asciiCodeB \u548c asciiCodeC \u4e2d\u3002<\/p>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0cTypeScript \u4e2d\u7684 charCodeAt() \u65b9\u6cd5\u53ef\u4ee5\u7528\u65bc\u6c42\u5f97\u5b57\u4e32\u4e2d\u6bcf\u500b\u5b57\u5143\u7684 ASCII \u78bc\uff0c\u4f7f\u7528\u8d77\u4f86\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528TypeScript\u5b57\u4e32\u7684\u6c42ASCII\u78bc(charCodeAt)\u529f\u80fd\uff0c\u53ef\u4ee5\u8b93\u4f60\u66f4\u6709\u6548\u7387\u7684\u8655\u7406\u5b57\u4e32\uff0c\u4e26\u4e14\u66f4\u5bb9\u6613\u5730\u5c0d\u5b57\u4e32\u9032\u884c\u64cd\u4f5c\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-5036","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-1je","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5036","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=5036"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5036\/revisions"}],"predecessor-version":[{"id":5037,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5036\/revisions\/5037"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}