分割能用其他符号吗?

来源:7-9 字符串分割split()

Rongdd

2015-07-13 10:56

分割只能用,号(逗号)吗?

写回答 关注

4回答

  • inro
    2016-03-28 11:42:27

    这样理解就很容易了:  字符串用split进行分割以后所以就成为了一个数组,例如:

    var mychar="hello,javascript";

    进行分割以后就变成了这样一个样子:["h","e","l","l","0",",","j","a","v","a","s","c","r","i","p","t"]

    定义数组的时候: var myarry=["h","e","l","l","0",",","j","a","v","a","s","c","r","i","p","t"]

    所以在用document.write()进行输出的时候中间是用“,”作为分割的。

  • 灿白
    2015-07-22 15:54:53

    是这样的,对于字符"-"用来代码制定划分数字,对于字符"."是用来划分字母的,最后显示出来是逗号。其实就是相应字符串分割成相应的字符。

  • arlenhui
    2015-07-13 13:36:39

    分割是将string转化成数组,所以打印出来时是逗号分割

  • 康振宁
    2015-07-13 11:26:49

    不能。

JavaScript进阶篇

本课程从如何插入JS代码开始,带您进入网页动态交互世界

468195 学习 · 21891 问题

查看课程

相似问题