其他分享
首页 > 其他分享> > Array.prototype.join()

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