购物车
登陆 / 注册
微信扫码登陆

推荐手册

ES 6 String substring()

substring()方法返回String对象的子集。

语法:

string.substring(indexA, [indexB])

参数:

● indexA:0到1之间的整数,小于字符串的长度。

● indexB:(可选)0到字符串长度之间的整数。

返回值:

该子方法返回根据给定参数的新子。

例:

var str = "Apples are round, and apples are juicy."; 
console.log("(1,2): "    + str.substring(1,2)); 
console.log("(0,10): "   + str.substring(0, 10)); 
console.log("(5): "      + str.substring(5));

返回值:

(1,2): p 
(0,10): Apples are 
(5): s are round, and apples are juicy
网站导航
标签地图
学习路径
视频教程
开发软件
旗下子站
php中文网
phpstudy
技术文章
文档工具
关于我们
企业合作
人才招聘
联系我们
讲师招募
QQ交流群
QQ官方交流群
微信公众号
微信公众号