JavaScript中substr和substring的区别: JavaScript中String 对象的slice()、substring()、substr()方法都能提取字符串的一部分,但使用时有所区别。
返回字符串 stringObject 从 startIndex 开始(包括 startIndex )到 endIndex 结束(不包括 endIndex )为止的所有字符。
var stringObject = "hello world!"; alert(stringObject.slice(3)); // lo world! alert(stringObject.slice(3,stringObject.length)); // lo world!
var stringObject = "hello world!"; alert(stringObject.slice(-3));
Last updated:2010-03-31
|
