String.prototype.concat()segmentfault
concat()
方法將一個或多個字符串與原字符串鏈接合併,造成一個新的字符串並返回,不影響原字符串。瀏覽器
str.concat(string2, string3[, ..., stringN])
string2...stringN
和原字符串鏈接的多個字符串性能
concat
方法將一個或多個字符串與原字符串鏈接合併,造成一個新的字符串並返回。 concat
方法並不影響原字符串。prototype
下面的例子演示如何將多個字符串與原字符串合併爲一個新字符串。code
var hello = "Hello, "; console.log(hello.concat("Kevin", " have a nice day.")); /* Hello, Kevin have a nice day. */
強烈建議使用 賦值操做符(+, +=
)代替 concat
方法。參看 幾種評價字符串方法的性能比較。字符串
全平臺支持。get