Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

js string substring

作者:翻成云恨雨愁   发布日期:2026-03-21   浏览:93

// 示例代码:使用 substring 方法提取字符串的子串

let str = "Hello, world!";
let result = str.substring(7, 12); // 提取从索引 7 到 12(不包括 12)的子串
console.log(result); // 输出: world

// 解释说明:
// substring 方法用于提取字符串中介于两个指定下标之间的字符。
// 语法:string.substring(start, end)
// 参数 start:必需,要抽取的子串的起始下标。必须是有效索引。
// 参数 end:可选,结束抽取的位置。必须是有效索引。如果省略,那么返回的子串会一直到字符串的结尾。

上一篇:js substring截取字符串

下一篇:js substr和substring的区别

大家都在看

js 数组打乱顺序

js 两个数组取交集

js 数组对象排序

js 对象数组排序

js 数组删掉第一个值

js fill

js 数组连接

js json数组

js 数组复制

js 复制数组

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站