{"id":5627,"date":"2023-01-06T10:57:06","date_gmt":"2023-01-06T02:57:06","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=5627"},"modified":"2023-01-06T10:57:06","modified_gmt":"2023-01-06T02:57:06","slug":"%e4%ba%86%e8%a7%a3react-js%e4%b8%adendswith%e5%87%bd%e6%95%b8%e7%9a%84%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/react-js\/%e4%ba%86%e8%a7%a3react-js%e4%b8%adendswith%e5%87%bd%e6%95%b8%e7%9a%84%e5%8a%9f%e8%83%bd\/","title":{"rendered":"\u4e86\u89e3React.JS\u4e2dendsWith()\u51fd\u6578\u7684\u529f\u80fd"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"React.JS, endsWith\"><\/p>\n<h1>\u4f7f\u7528 React.JS \u5224\u65b7\u5b57\u4e32\u662f\u5426\u4ee5\u7279\u5b9a\u5b57\u7b26\u4e32\u7d50\u5c3e<\/h1>\n<p>React.JS \u662f\u4e00\u500b\u7528\u65bc\u69cb\u5efa\u7528\u6236\u754c\u9762\u7684 JavaScript \u5eab\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u8f15\u9b06\u5730\u69cb\u5efa\u9ad8\u6027\u80fd\u7684\u7db2\u9801\u61c9\u7528\u7a0b\u5e8f\u3002\u5728 React.JS \u4e2d\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u4f7f\u7528\u5167\u7f6e\u7684\u65b9\u6cd5\u4f86\u5224\u65b7\u5b57\u4e32\u662f\u5426\u4ee5\u7279\u5b9a\u5b57\u7b26\u4e32\u7d50\u5c3e\u3002<\/p>\n<h2>endsWith \u65b9\u6cd5<\/h2>\n<p>React.JS \u4e2d\u7684 <code>endsWith<\/code> \u65b9\u6cd5\u53ef\u4ee5\u7528\u65bc\u5224\u65b7\u5b57\u4e32\u662f\u5426\u4ee5\u7279\u5b9a\u5b57\u7b26\u4e32\u7d50\u5c3e\u3002\u5b83\u63a5\u53d7\u5169\u500b\u53c3\u6578\uff1a\u8981\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\u548c\u8981\u6bd4\u8f03\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c\u8981\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\u4ee5\u8981\u6bd4\u8f03\u7684\u5b57\u7b26\u4e32\u7d50\u5c3e\uff0c\u5247\u8fd4\u56de <code>true<\/code>\uff0c\u5426\u5247\u8fd4\u56de <code>false<\/code>\u3002<\/p>\n<pre class=\"brush: javascript\">\nlet str = 'Hello World';\nlet endsWith = str.endsWith('World');\nconsole.log(endsWith); \/\/ true\n<\/pre>\n<p>\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 <code>endsWith<\/code> \u65b9\u6cd5\u4f86\u6aa2\u67e5\u5b57\u7b26\u4e32 <code>'Hello World'<\/code> \u662f\u5426\u4ee5 <code>'World'<\/code> \u7d50\u5c3e\uff0c\u7d50\u679c\u8fd4\u56de <code>true<\/code>\u3002<\/p>\n<h2>\u7b2c\u4e8c\u500b\u53c3\u6578<\/h2>\n<p>\u9664\u4e86\u8981\u6bd4\u8f03\u7684\u5b57\u7b26\u4e32\u5916\uff0c<code>endsWith<\/code> \u65b9\u6cd5\u9084\u63a5\u53d7\u4e00\u500b\u53ef\u9078\u7684\u7b2c\u4e8c\u500b\u53c3\u6578\uff0c\u5b83\u53ef\u4ee5\u7528\u65bc\u6307\u5b9a\u8981\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\u7684\u9577\u5ea6\u3002\u4f8b\u5982\uff0c\u5982\u679c\u6211\u5011\u60f3\u6aa2\u67e5\u5b57\u7b26\u4e32 <code>'Hello World'<\/code> \u662f\u5426\u4ee5 <code>'Hello'<\/code> \u7d50\u5c3e\uff0c\u6211\u5011\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u78bc\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet str = 'Hello World';\nlet endsWith = str.endsWith('Hello', 5);\nconsole.log(endsWith); \/\/ true\n<\/pre>\n<p>\u5728\u9019\u500b\u793a\u4f8b\u4e2d\uff0c\u6211\u5011\u6307\u5b9a\u4e86\u7b2c\u4e8c\u500b\u53c3\u6578 <code>5<\/code>\uff0c\u5b83\u8868\u793a\u6211\u5011\u53ea\u60f3\u6aa2\u67e5\u5b57\u7b26\u4e32 <code>'Hello World'<\/code> \u7684\u524d 5 \u500b\u5b57\u7b26\uff0c\u4e5f\u5c31\u662f <code>'Hello'<\/code>\uff0c\u7d50\u679c\u8fd4\u56de <code>true<\/code>\u3002<\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5b78\u7fd2\u4e86\u5982\u4f55\u4f7f\u7528 React.JS \u4e2d\u7684 <code>endsWith<\/code> \u65b9\u6cd5\u4f86\u5224\u65b7\u5b57\u4e32\u662f\u5426\u4ee5\u7279\u5b9a\u5b57\u7b26\u4e32\u7d50\u5c3e\u3002<code>endsWith<\/code> \u65b9\u6cd5\u63a5\u53d7\u5169\u500b\u53c3\u6578\uff1a\u8981\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\u548c\u8981\u6bd4\u8f03\u7684\u5b57\u7b26\u4e32\uff0c\u5b83\u9084\u63a5\u53d7\u4e00\u500b\u53ef\u9078\u7684\u7b2c\u4e8c\u500b\u53c3\u6578\uff0c\u7528\u65bc\u6307\u5b9a\u8981\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\u7684\u9577\u5ea6\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u5982\u679c\u8981\u6aa2\u67e5\u7684\u5b57\u7b26\u4e32\u4ee5\u8981\u6bd4\u8f03\u7684\u5b57\u7b26\u4e32\u7d50\u5c3e\uff0c\u5247\u8fd4\u56de <code>true<\/code>\uff0c\u5426\u5247\u8fd4\u56de <code>false<\/code>\u3002\u901a\u904e\u4f7f\u7528 <code>endsWith<\/code> \u65b9\u6cd5\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u8f15\u9b06\u5730\u6aa2\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4ee5\u7279\u5b9a\u5b57\u7b26\u4e32\u7d50\u5c3e\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u69cb\u5efa\u9ad8\u6027\u80fd\u7684\u7db2\u9801\u61c9\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981(Description):\u4e86\u89e3React.JS\u4e2dendsWith()\u51fd\u6578\u7684\u529f\u80fd\uff0c\u5b83\u53ef\u4ee5\u7528\u4f86\u5224\u65b7\u5b57\u4e32\u662f\u5426\u4ee5\u7279\u5b9a\u5b57\u7b26\u4e32\u7d50\u5c3e\uff0c\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5f0f\u7684\u57f7\u884c\u6548\u7387\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":[184,183],"tags":[182,181],"class_list":["post-5627","post","type-post","status-publish","format-standard","hentry","category-react","category-react-js","tag-react","tag-react-js"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1sL","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5627","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=5627"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5627\/revisions"}],"predecessor-version":[{"id":5628,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/5627\/revisions\/5628"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=5627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=5627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=5627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}