JS中的substring和substr函数的区别

1. 在JS中, 函数声明: stringObject.substring(start,stop)

 

  start是在原字符串检索的开始位置,stop是检索的终止位置,返回结果中不包括stop所指字符.JS中的substring和substr函数的区别

如:"hamburger".substring(4,8) returns "urge"

2. substr(start,length)

如:当DETAIL_TYPE 的值为1111053 时, substr(DETAIL_TYPE,1,6)  = 111105  从DETAIL_TYPE的第一位开始取六位字符。

原文地址:https://www.cnblogs.com/pengchong/p/3021817.html