Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

String.prototype.concat()

concat() 方法将一个或多个字符串与原字符串连接合并,形成一个新的字符串并返回。

语法

str.concat(string2string3[, ..., stringN])

参数

string2...stringN
和原字符串连接的多个字符串

描述

concat 方法将一个或多个字符串与原字符串连接合并,形成一个新的字符串并返回。 concat 方法并不影响原字符串。

示例

例子:使用 concat

下面的例子演示如何将多个字符串与原字符串合并为一个新字符串

var hello = "Hello, ";
console.log(hello.concat("Kevin", " have a nice day.")); /* Hello, Kevin have a nice day. */

性能

强烈建议使用 赋值操作符(+, +=)代替 concat 方法。参看 性能测试(perfomance test)

规范

Specification Status Comment
ECMAScript 3rd Edition (ECMA-262) Standard Initial definition. Implemented in JavaScript 1.2.
ECMAScript 5.1 (ECMA-262)
String.prototype.concat
Standard  
ECMAScript 2015 (6th Edition, ECMA-262)
String.prototype.concat
Standard  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

相关链接

文档标签和贡献者

 此页面的贡献者: Skyang, yenshen, teoli, AlexChao, ziyunfei
 最后编辑者: Skyang,