我在 javascript 中有这个字符串:
var st="ab,cd,ef,gh";
如何使这个字符串成为长度等于 4 的数组示例:
st should be like this : [ab cd ef gh]
最佳答案
使用split(..)
st.split(",")
输出:
["ab", "cd", "ef", "gh"]
关于javascript - 如何将字符串转换为特定分隔符下的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12138804/