Home > Web Front-end > JS Tutorial > body text

javascript: concatenating string function concat()

高洛峰
Release: 2016-11-16 10:39:14
Original
2863 people have browsed it

String.prototype.concat()

concat() method connects and merges one or more strings with the original string to form a new string and return it, without affecting the original string.

Syntax

str.concat(string2, string3[, ..., stringN])
Copy after login

Parameters

string2...stringN
Copy after login

Multiple strings connected to the original string

Description

concat method combines one or more strings with the original string to form a new string and returns it. The concat method does not affect the original string.

Example

The following example demonstrates how to merge multiple strings with the original string into a new string.

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

Performance

It is strongly recommended to use assignment operators (+, +=) instead of concat method.

Browser compatibility

Full platform support.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!