Array.prototype.join()
作者:互联网
Array.prototype.join()
将数组转换为字符串,不会改变原数组
- 无参情况(默认用逗号分隔)
let arr=['jack','tom','mary']
console.log(arr.join()); //jack,tom,mary
- 有参情况
let arr=['jack','tom','mary']
console.log(arr.join('and')); //jackandtomandmary
//还可以这样,让它们换行
let arr=['jack','tom','mary']
console.log(arr.join('\n'));
// jack
// tom
// mary
标签:arr,join,log,jack,tom,Array,prototype,mary 来源: https://www.cnblogs.com/zhumenglong/p/16341942.html