{"id":5220,"date":"2023-01-05T12:13:42","date_gmt":"2023-01-05T04:13:42","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5220"},"modified":"2023-01-05T12:13:42","modified_gmt":"2023-01-05T04:13:42","slug":"%e4%ba%86%e8%a7%a3typescript%e5%ad%97%e4%b8%b2%e7%9a%84startswith%e5%87%bd%e6%95%b8%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%84startswith%e5%87%bd%e6%95%b8%e5%8a%9f%e8%83%bd\/","title":{"rendered":"\u4e86\u89e3TypeScript\u5b57\u4e32\u7684startsWith()\u51fd\u6578\u529f\u80fd"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, startsWith\"><\/p>\n<p>TypeScript \u662f\u4e00\u7a2e JavaScript \u7684\u8d85\u96c6\uff0c\u5b83\u63d0\u4f9b\u4e86\u5f37\u5927\u7684\u985e\u578b\u6aa2\u67e5\u529f\u80fd\uff0c\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u958b\u767c\u51fa\u5065\u58ef\u7684\u7a0b\u5f0f\u78bc\u3002\u5728 TypeScript \u4e2d\uff0c\u5b57\u4e32\u4e5f\u6709\u4e00\u4e9b\u6709\u7528\u7684\u65b9\u6cd5\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f startsWith\uff0c\u5b83\u53ef\u4ee5\u7528\u4f86\u6aa2\u67e5\u4e00\u500b\u5b57\u4e32\u662f\u5426\u4ee5\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u958b\u982d\u3002<\/p>\n<p><!--more--><\/p>\n<p>startsWith \u65b9\u6cd5\u63a5\u53d7\u5169\u500b\u53c3\u6578\uff0c\u7b2c\u4e00\u500b\u53c3\u6578\u662f\u8981\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\uff0c\u7b2c\u4e8c\u500b\u53c3\u6578\u662f\u8981\u6aa2\u67e5\u7684\u958b\u982d\u5b57\u7b26\u4e32\u3002\u5982\u679c\u8981\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\u4ee5\u6307\u5b9a\u7684\u958b\u982d\u5b57\u7b26\u4e32\u958b\u982d\uff0c\u5247\u6703\u8fd4\u56de true\uff0c\u5426\u5247\u6703\u8fd4\u56de false\u3002<\/p>\n<pre class=\"brush: typescript\">\nlet str = \"Hello World\";\nlet result = str.startsWith(\"Hello\");\nconsole.log(result); \/\/ true\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 startsWith \u65b9\u6cd5\u4f86\u6aa2\u67e5\u5b57\u7b26\u4e32 str \u662f\u5426\u4ee5 &#8220;Hello&#8221; \u958b\u982d\uff0c\u7531\u65bc\u5b57\u7b26\u4e32 str \u78ba\u5be6\u4ee5 &#8220;Hello&#8221; \u958b\u982d\uff0c\u56e0\u6b64\u6703\u8fd4\u56de true\u3002<\/p>\n<p>\u6b64\u5916\uff0cstartsWith \u65b9\u6cd5\u9084\u53ef\u4ee5\u63a5\u53d7\u7b2c\u4e09\u500b\u53c3\u6578\uff0c\u7528\u65bc\u6307\u5b9a\u8981\u6aa2\u67e5\u7684\u958b\u982d\u5b57\u7b26\u4e32\u7684\u9577\u5ea6\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6211\u5011\u60f3\u6aa2\u67e5\u5b57\u7b26\u4e32 str \u662f\u5426\u4ee5 &#8220;He&#8221; \u958b\u982d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u7a0b\u5f0f\u78bc\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet str = \"Hello World\";\nlet result = str.startsWith(\"He\", 2);\nconsole.log(result); \/\/ true\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u6307\u5b9a\u7b2c\u4e09\u500b\u53c3\u6578\u70ba 2\uff0c\u8868\u793a\u8981\u6aa2\u67e5\u5b57\u7b26\u4e32 str \u662f\u5426\u4ee5 &#8220;He&#8221; \u958b\u982d\uff0c\u800c\u4e0d\u662f &#8220;Hello&#8221;\u3002\u7531\u65bc\u5b57\u7b26\u4e32 str \u78ba\u5be6\u4ee5 &#8220;He&#8221; \u958b\u982d\uff0c\u56e0\u6b64\u6703\u8fd4\u56de true\u3002<\/p>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0cstartsWith \u65b9\u6cd5\u53ef\u4ee5\u7528\u4f86\u6aa2\u67e5\u4e00\u500b\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u958b\u982d\uff0c\u5b83\u53ef\u4ee5\u63a5\u53d7\u5169\u500b\u6216\u4e09\u500b\u53c3\u6578\uff0c\u7b2c\u4e00\u500b\u53c3\u6578\u662f\u8981\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\uff0c\u7b2c\u4e8c\u500b\u53c3\u6578\u662f\u8981\u6aa2\u67e5\u7684\u958b\u982d\u5b57\u7b26\u4e32\uff0c\u7b2c\u4e09\u500b\u53c3\u6578\u662f\u8981\u6aa2\u67e5\u7684\u958b\u982d\u5b57\u7b26\u4e32\u7684\u9577\u5ea6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3TypeScript\u5b57\u4e32\u7684startsWith()\u51fd\u6578\u529f\u80fd\uff0c\u5b83\u53ef\u4ee5\u6aa2\u67e5\u5b57\u4e32\u662f\u5426\u4ee5\u6307\u5b9a\u5b57\u7b26\u4e32\u958b\u982d\uff0c\u4e26\u8fd4\u56de\u5e03\u6797\u503c\u3002\u672c\u6587\u5c07\u4ecb\u7d39startsWith()\u51fd\u6578\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u4ee5\u53ca\u5b83\u7684\u512a\u9ede\u548c\u7f3a\u9ede\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-5220","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-1mc","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5220","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=5220"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5220\/revisions"}],"predecessor-version":[{"id":5221,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5220\/revisions\/5221"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}