js 字符串截取倒数第三个字符
时间: 2023-10-17 18:34:55 浏览: 154
js 中截取字符串的三个方法 substring、substr、slice
要截取js字符串的倒数第三个字符,可以使用substr()方法和负数索引。根据引用中的说明,负数索引表示字符串的倒数第几个字符。假设字符串为str,可以使用str.substr(-3, 1)来截取倒数第三个字符。其中,-3表示倒数第三个字符的索引,1表示截取的字符个数。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [js截取字符串-三种方法](https://download.csdn.net/download/qq_59708493/87293853)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [js字符串截取的3中方法你分的清吗?](https://blog.csdn.net/dong_dong222/article/details/123500436)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [JavaScript字符串截取方法](https://blog.csdn.net/Anthony1021/article/details/130285865)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文