欢迎光临
我们一直在努力

string.substring();

建站超值云服务器,限时71元/月

substring method
returns the substring at the specified location within a string object.

strvariable.substring(start, end)
"string literal".substring(start, end)

arguments
start

the zero-based index integer indicating the beginning of the substring.

end

the zero-based index integer indicating the end of the substring.

remarks
the substring method returns a string containing the substring from start up to, but not including, end.

the substring method uses the lower value of start and end as the beginning point of the substring. for example, strvar.substring(0, 3) and strvar.substring(3, 0) return the same substring.

if either start or end is nan or negative, it is replaced with zero.

the length of the substring is equal to the absolute value of the difference between start and end. for example, the length of the substring returned in strvar.substring(0, 3) and strvar.substring(3, 0) is three.

example
the following example illustrates the use of the substring method.

function substringdemo(){
   var ss;                         //declare variables.
   var s = "the rain in spain falls mainly in the plain..";
   ss = s.substring(12, 17);   //get substring.
   return(ss);                     //return substring.
}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » string.substring();
分享到: 更多 (0)

相关推荐

  • 暂无文章