💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] # 数组转字符串 ## 第一种方法:join ``` <script> var casts = [ { name: "张三" }, { name: "李四" }, { name: "王五" }, ]; var arr=[]; casts.forEach(ele=>{ arr.push(ele.name); }) var newArr = arr.join("/"); console.log(newArr); //张三/李四/王五 </script> ``` ## 第二种方法 ``` <script> var casts = [ { name: "张三" }, { name: "李四" }, { name: "王五" }, ]; var str=""; casts.forEach(ele=>{ str = str+ele.name+"/"; }) str = str.slice(0,str.length-1); console.log(str); </script> ```