js字符串格式化数组
时间: 2023-09-26 22:10:50 浏览: 110
你可以使用以下方法将一个带逗号的字符串格式化为数组的形式:
```javascript
function changearray(s){
var ar = new Array();
ar = s.split(",");
return ar;
}
```
这个方法将输入的字符串通过逗号分隔符分离为多个元素,并将这些元素保存在一个数组中。你可以调用这个函数并传入一个带逗号的字符串作为参数,然后得到一个包含分隔后的元素的数组作为结果。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [针对字符串转为数组并格式化转为字符串js实现方式](https://blog.csdn.net/weixin_34297704/article/details/91944008)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Emoji转换工具,便于各种类型的客户端生成的Emoji字符串转换成另外一种格式](https://download.csdn.net/download/ldk99_/88222486)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [php 字符串内容是数组格式 转换成数组](https://blog.csdn.net/weixin_30810239/article/details/98292869)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文