如何在JavaScript中将字符数组转换为字符串?
var s = ['H', 'e', 'l', 'l', 'o'];
// How to convert s to a string?
答案 0 :(得分:93)
使用join
:
string = s.join("");
答案 1 :(得分:6)
你这样做:
var str = s.join();
答案 2 :(得分:5)
或使用String。
var string = String([1,2,3]);
答案 3 :(得分:4)
join命令允许您在数组中的项目之间设置标记。
练习1:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="result"></div>
&#13;
CREATE TABLE table_name ( name VARCHAR(50) );
INSERT INTO table_name
SELECT 'AE 344592001H 6186694' UNION ALL
SELECT 'AE_161038002_6044777' UNION ALL
SELECT 'BC_VIVS_HNB011A_1WAM' UNION ALL
SELECT 'BC_56230A_30SP' UNION ALL
SELECT 'CG_3334902_NETWK_ ACTLM_3334912' UNION ALL
SELECT 'CG_3334574_HMO1_CORACT_3334575' UNION ALL
SELECT 'CG_3207160_POSC_1502AH_3207161' UNION ALL
SELECT 'UH_141015_RHM' UNION ALL
SELECT 'UH_127757_RIV' UNION ALL
SELECT 'UH 523725 RIV' UNION ALL
SELECT 'BS_W0055785_C500_M0005672';
&#13;
答案 4 :(得分:0)
这是最简单,最快捷的方式;
s = s + '';