码迷,mamicode.com
首页 > Web开发 > 详细

JS 中的substring ,substr ,slice,split,join

时间:2016-06-07 14:26:15      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

  1. substr with different arguments passed in:
    1. str.substring(startNum,stopNum );
    2. str.slice(startNum,stopNum );
    3. str.substr(startNum,length );
  2. substring vs slice
    1. start = stop ,return ‘ ‘; the same.
    2. start or stop bigger than str.length, it will make the bigger one equal str.length.
    3. start < 0 || stop < 0,  substring will make it equal 0, but slice won’t do like this.
    4. start > stop ,substring will swap those two arguments, but slice won’t do like this.
  3. str.split(‘&‘,num )  < ==  == > array.join(‘&’);

JS 中的substring ,substr ,slice,split,join

标签:

原文地址:http://www.cnblogs.com/Slim-Shady/p/5566563.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!