js數(shù)組如何轉(zhuǎn)化為字符串
1、使用 toString 方法。例:
var arr = ['a','b','c','d'] var str = arr.toString(); console.log(str); //輸出:a,b,c,d console.log(typeof str); //輸出:string
2、使用 join 方法。例:文章來源:http://www.zghlxwxcb.cn/article/91.html
var a = ['a','b','c','d'] arr.join(",") console.log(arr); //輸出:a,b,c,d console.log(typeof s); //輸出:string
文章來源地址http://www.zghlxwxcb.cn/article/91.html
到此這篇關(guān)于js數(shù)組如何轉(zhuǎn)化為字符串,特定符號轉(zhuǎn)化字符串的文章就介紹到這了,更多相關(guān)內(nèi)容可以在右上角搜索或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!