search

Home  >  Q&A  >  body text

Why is split in JavaScript not a function?

console.log(str);

为情所困为情所困2748 days ago902

reply all(9)I'll reply

  • 世界只因有你

    世界只因有你2017-06-15 09:23:37

    Str is a string?

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-06-15 09:23:37

    Output the type of your str to see
    split is a string method

    reply
    0
  • 某草草

    某草草2017-06-15 09:23:37

    Is str itself not a string? split is a method in a string

    reply
    0
  • 三叔

    三叔2017-06-15 09:23:37

    Confirm whether str is a String Object. Split is a function, that’s right

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-15 09:23:37

    split() is a method of String. The str you print out is obviously an array

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-15 09:23:37

    Your str is not a string type number, and the split method does not exist in arrays.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-15 09:23:37

    It should be a method under a certain class, a method under string. Can’t be taken out separately, use it directly

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-06-15 09:23:37

    Convert arr to string, then use this method

    reply
    0
  • PHP中文网

    PHP中文网2017-06-15 09:23:37

    You should first convert arr to string and then use split

    reply
    0
  • Cancelreply