{"id":5236,"date":"2023-01-05T12:15:52","date_gmt":"2023-01-05T04:15:52","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5236"},"modified":"2023-01-05T12:15:52","modified_gmt":"2023-01-05T04:15:52","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8typescript%e4%b8%ad%e7%9a%84includes%e5%87%bd%e6%95%b8%e4%be%86%e6%aa%a2%e6%9f%a5%e5%ad%97%e4%b8%b2","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%e4%b8%ad%e7%9a%84includes%e5%87%bd%e6%95%b8%e4%be%86%e6%aa%a2%e6%9f%a5%e5%ad%97%e4%b8%b2\/","title":{"rendered":"\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528TypeScript\u4e2d\u7684includes()\u51fd\u6578\u4f86\u6aa2\u67e5\u5b57\u4e32"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, \u5b57\u4e32, \u6c42\u662f\u5426\u5305\u542b\u6307\u5b9a\u5b57\u7b26\u4e32, includes\"><\/p>\n<h1>TypeScript \u5b57\u4e32\u7684\u6c42\u662f\u5426\u5305\u542b\u6307\u5b9a\u5b57\u7b26\u4e32(includes)<\/h1>\n<p>TypeScript \u662f\u4e00\u7a2e JavaScript \u7684\u8d85\u96c6\uff0c\u5b83\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u529f\u80fd\uff0c\u8b93\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u8f15\u9b06\u5730\u958b\u767c\u51fa\u66f4\u512a\u8cea\u7684\u7a0b\u5f0f\u78bc\u3002\u5176\u4e2d\u4e00\u500b\u529f\u80fd\u5c31\u662f\u63d0\u4f9b\u4e86\u4e00\u500b includes() \u65b9\u6cd5\uff0c\u53ef\u4ee5\u7528\u4f86\u6aa2\u67e5\u5b57\u4e32\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<p>includes() \u65b9\u6cd5\u53ef\u4ee5\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\u6aa2\u67e5\u7684\u958b\u59cb\u4f4d\u7f6e\uff0c\u5982\u679c\u7701\u7565\u7b2c\u4e8c\u500b\u53c3\u6578\uff0c\u5247\u9810\u8a2d\u70ba 0\uff0c\u4e5f\u5c31\u662f\u5f9e\u5b57\u4e32\u7684\u958b\u982d\u958b\u59cb\u6aa2\u67e5\u3002<\/p>\n<p>includes() \u65b9\u6cd5\u6703\u56de\u50b3\u4e00\u500b\u5e03\u6797\u503c\uff0c\u5982\u679c\u5b57\u4e32\u4e2d\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\uff0c\u5247\u56de\u50b3 true\uff0c\u53cd\u4e4b\u5247\u56de\u50b3 false\u3002<\/p>\n<h2>TypeScript includes() \u65b9\u6cd5\u7bc4\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u7c21\u55ae\u7684\u7bc4\u4f8b\uff0c\u7528\u4f86\u6aa2\u67e5\u5b57\u4e32\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet str = \"Hello World\";\nlet result = str.includes(\"World\");\nconsole.log(result); \/\/ true\n<\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u5ba3\u544a\u4e86\u4e00\u500b\u5b57\u4e32 str\uff0c\u4e26\u4f7f\u7528 includes() \u65b9\u6cd5\u6aa2\u67e5\u5b57\u4e32\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\u4e32 &#8220;World&#8221;\uff0c\u6700\u5f8c\u5c07\u7d50\u679c\u8f38\u51fa\u5230\u63a7\u5236\u53f0\uff0c\u7d50\u679c\u70ba true\uff0c\u8868\u793a\u5b57\u4e32\u4e2d\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<h2>TypeScript includes() \u65b9\u6cd5\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>includes() \u65b9\u6cd5\u662f\u5927\u5c0f\u5beb\u654f\u611f\u7684\uff0c\u4e5f\u5c31\u662f\u8aaa\uff0c\u5982\u679c\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\u548c\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u5927\u5c0f\u5beb\u4e0d\u4e00\u81f4\uff0c\u5247\u6703\u56de\u50b3 false\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u6211\u5011\u5728\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e2d\uff0c\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\u662f &#8220;World&#8221;\uff0c\u800c\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u662f &#8220;world&#8221;\uff0c\u5247\u6703\u56de\u50b3 false\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet str = \"Hello World\";\nlet result = str.includes(\"world\");\nconsole.log(result); \/\/ false\n<\/pre>\n<p>\u56e0\u6b64\uff0c\u5728\u4f7f\u7528 includes() \u65b9\u6cd5\u6642\uff0c\u8981\u7279\u5225\u6ce8\u610f\u5927\u5c0f\u5beb\u7684\u554f\u984c\u3002<\/p>\n<p><!--more--><\/p>\n<h2>TypeScript includes() \u65b9\u6cd5\u61c9\u7528<\/h2>\n<p>includes() \u65b9\u6cd5\u53ef\u4ee5\u7528\u4f86\u6aa2\u67e5\u5b57\u4e32\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u7528\u4f86\u505a\u5f88\u591a\u6709\u8da3\u7684\u4e8b\u60c5\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u6aa2\u67e5\u7528\u6236\u8f38\u5165\u7684\u5bc6\u78bc\u662f\u5426\u7b26\u5408\u898f\u5247\uff0c\u4f8b\u5982\uff1a\u5bc6\u78bc\u4e2d\u662f\u5426\u5305\u542b\u82f1\u6587\u5b57\u6bcd\u3001\u6578\u5b57\u7b49\u3002<\/li>\n<li>\u6aa2\u67e5\u7528\u6236\u8f38\u5165\u7684\u96fb\u5b50\u90f5\u4ef6\u5730\u5740\u662f\u5426\u6b63\u78ba\uff0c\u4f8b\u5982\uff1a\u96fb\u5b50\u90f5\u4ef6\u5730\u5740\u4e2d\u662f\u5426\u5305\u542b &#8220;@&#8221; \u7b26\u865f\u3002<\/li>\n<li>\u6aa2\u67e5\u7528\u6236\u8f38\u5165\u7684 URL \u662f\u5426\u6b63\u78ba\uff0c\u4f8b\u5982\uff1aURL \u4e2d\u662f\u5426\u5305\u542b &#8220;http&#8221; \u6216 &#8220;https&#8221; \u7b49\u3002<\/li>\n<\/ul>\n<p>\u53e6\u5916\uff0cincludes() \u65b9\u6cd5\u4e5f\u53ef\u4ee5\u7528\u4f86\u6aa2\u67e5\u5b57\u4e32\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: typescript\">\nlet str = \"Hello World\";\nlet result = str.includes(\"o\");\nconsole.log(result); \/\/ true\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 includes() \u65b9\u6cd5\u6aa2\u67e5\u5b57\u4e32\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26 &#8220;o&#8221;\uff0c\u7d50\u679c\u70ba true\uff0c\u8868\u793a\u5b57\u4e32\u4e2d\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\u3002<\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>includes() \u65b9\u6cd5\u662f TypeScript \u4e2d\u4e00\u500b\u975e\u5e38\u5be6\u7528\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u7528\u4f86\u6aa2\u67e5\u5b57\u4e32\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u6216\u5b57\u7b26\uff0c\u53ef\u4ee5\u7528\u4f86\u505a\u5f88\u591a\u6709\u8da3\u7684\u4e8b\u60c5\uff0c\u4f8b\u5982\u6aa2\u67e5\u7528\u6236\u8f38\u5165\u7684\u5bc6\u78bc\u3001\u96fb\u5b50\u90f5\u4ef6\u5730\u5740\u3001URL \u7b49\u662f\u5426\u6b63\u78ba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528TypeScript\u4e2d\u7684includes()\u51fd\u6578\u4f86\u6aa2\u67e5\u5b57\u4e32\uff0cincludes()\u51fd\u6578\u53ef\u4ee5\u8b93\u4f60\u6aa2\u67e5\u5b57\u4e32\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\uff0c\u8b93\u4f60\u53ef\u4ee5\u66f4\u6709\u6548\u7387\u5730\u6aa2\u67e5\u5b57\u4e32\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-5236","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-1ms","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5236","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=5236"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5236\/revisions"}],"predecessor-version":[{"id":5237,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5236\/revisions\/5237"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}