日期:2014-05-16 浏览次数:20380 次
var str = "0123456789"; alert(str.substring(0));------------"0123456789" alert(str.substring(5));------------"56789" alert(str.substring(10));-----------"" alert(str.substring(12));-----------"" alert(str.substring(-5));-----------"0123456789" alert(str.substring(-10));----------"0123456789" alert(str.substring(-12));----------"0123456789" alert(str.substring(0,5));----------"01234" alert(str.substring(0,10));---------"0123456789" alert(str.substring(0,12));---------"0123456789" alert(str.substring(2,0));----------"01" alert(str.substring(2,2));----------"" alert(str.substring(2,5));----------"234" alert(str.substring(2,12));---------"23456789" alert(str.substring(2,-2));---------"01" alert(str.substring(-1,5));---------"01234" alert(str.substring(-1,-5));--------"" alert(str.substr(0));---------------"0123456789" alert(str.substr(5));---------------"56789" alert(str.substr(10));--------------"" alert(str.substr(12));--------------"" alert(str.substr(-5));--------------"0123456789" alert(str.substr(-10));-------------"0123456789" alert(str.substr(-12));-------------"0123456789" alert(str.substr(0,5));-------------"01234" alert(str.substr(0,10));------------"0123456789" alert(str.substr(0,12));------------"0123456789" alert(str.substr(2,0));-------------"" alert(str.substr(2,2));-------------"23" alert(str.substr(2,5));-------------"23456" alert(str.substr(2,12));------------"23456789" alert(str.substr(2,-2));------------"" alert(str.substr(-1,5));------------"01234" alert(str.substr(-1,-5));-----------""