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

  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(‘&’);
上一篇:【AtCoder】ARC075


下一篇:JavaScript 字符串操作:substring, substr, slice