定义一个数组
var fruits = ["Banana", "Orange", "Apple", "Mango"];
使用join()方法
var energy = fruits.join();
输出energy
//Banana,Orange,Apple,Mango
console.log(energy);
总结
JavaScript Array join() 方法可以使数组拼接成字符串,并自动用‘’ , ‘’拼接
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var energy = fruits.join();
//Banana,Orange,Apple,Mango
console.log(energy);
JavaScript Array join() 方法可以使数组拼接成字符串,并自动用‘’ , ‘’拼接
评论