Home  >  Q&A  >  body text

Can use splice but cannot use substring

Why do I get an error when using substring for the same array?

迷茫迷茫2633 days ago847

reply all(4)I'll reply

  • 滿天的星座

    滿天的星座2017-07-05 10:50:09

    The

    substring() method is used to extract characters between two specified subscripts in a string.

    Syntax: stringObject.substring(start,stop)

    Cannot be used directly on arrays. Please refer to JavaScript substring() method

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-07-05 10:50:09

    substring, as the name suggests, is a function of string.

    reply
    0
  • 怪我咯

    怪我咯2017-07-05 10:50:09

    substring is used to operate strings. It is recommended to use slice instead.

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-07-05 10:50:09

    splice is the value returned by deletion, oppArr has been changed and becomes empty;
    splice(0) is to clear the array; slice(start, end) is to intercept the array and will not change the original array;
    substring is to intercept the string Method

    reply
    0
  • Cancelreply