Skip to content
陈广亮的技术博客
Go back

String.concat 与 apply 的妙用

将字符串 "a" 连接数组 ["b", "c"] 里的所有字符串:

// 文艺解法
String.prototype.concat.apply("a", ["b", "c"]); // "abc"

// 普通解法
["a", "b", "c"].join(""); // "abc"

Share this post on:

Previous Post
JS 类型转换:对象转原始值
Next Post
用按位非 ~ 简化 indexOf 判断