JavaScript字符串的操作

时间:2015-05-18 12:15:05   收藏:0   阅读:107
<script>
    var s=new String();
    var s="Hello World";
    alert(s.toLowerCase(s));//转小写
    alert(s.toUpperCase(s));//转大写 
    alert(s.substring(3,8));//从第3个位置截取到第8个位置
    alert(s.substr(3,8));//从第三个位置开始截取,截取8个字符长度
    alert(s.indexOf("World"));//Wodld第一次出现时的位置,没有的话就返回-1;
    alert(s.lastIndexOf("o"));//o在字符串中最后一次出现的位置;
</script>

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!