JavaScript String concat() 方法
- အရှေ့လမ်းကြောင်း codePointAt()
- နောက်လမ်းကြောင်း constructor
- အဆင်းကြမ်း ကြွေး JavaScript String လက်ဗိုက်စာရွက်
定义和用法
concat()
方法连接两个或多个字符串。
concat()
方法不会更改现有字符串。
concat()
方法返回新字符串。
实例
例子 1
连接两个字符串:
let text1 = "sea"; let text2 = "food"; let result = text1.concat(text2);
例子 2
连接两个字符串:
let text1 = "Hello"; let text2 = "world!"; let result = text1.concat(" ", text2);
例子 3
连接三个字符串:
let text1 = "Hello"; let text2 = "world!"; let text3 = "Have a nice day!"; let result = text1.concat(" ", text2, " ", text3);
语法
string.concat(string1, string2, ..., stringX)
参数
参数 | 描述 |
---|---|
string1, string2, ... stringX | 必需。要连接的字符串。 |
返回值
类型 | 描述 |
---|---|
字符串 | 包含被组合字符串的新字符串。 |
说明
方法 concat()
把它的所有参数都转换为字符串(如有必要),然后按顺序连接到字符串 string 的尾部,返回连接后的字符串。请注意,string ကိုမပြန်လည်ပြောင်းလဲမည်
String.concat()
နှင့် Array.concat()
အတူတူပါသည်။ သို့သော် 'ပြန်လည်ပေး' တရားသားအသုံးပြု၍ စကားလုံးများကို ပတ်သက်ပြီး သွက်သည့််
ဘရပ်သားများ ကူညီပြီးသည်
concat()
အက်စ်အက်စ်1 (ES1) သဘောတရသည်。
အားလုံးသော ဘရပ်သားများ အက်စ်အက်စ်1 (ဂျစ်တာစ် 1997) ကို အကောင့်ဆောင်ပြီးသည့််
ခရိုမို | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
ခရိုမို | IE | Edge | Firefox | Safari | Opera |
ထောက်ပံ့ | ထောက်ပံ့ | ထောက်ပံ့ | ထောက်ပံ့ | ထောက်ပံ့ | ထောက်ပံ့ |
- အရှေ့လမ်းကြောင်း codePointAt()
- နောက်လမ်းကြောင်း constructor
- အဆင်းကြမ်း ကြွေး JavaScript String လက်ဗိုက်စာရွက်