string.concat

๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ „๋‹ฌ๋ฐ›์€ ๋ชจ๋“  ๋ฌธ์ž์—ด์„ ๋ฌธ์ž์—ด๊ณผ ์—ฐ๊ฒฐํ•˜์—ฌ ์ƒˆ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

const str1 = "Hello";
const str2 = "world";

console.log(str1.concat(' ', str2)); // Hello world

Syntax

str.concat(str2 [, ...strN])

Parameters

str2, [, ...strN]

str์— ์—ฐ๊ฒฐ์‹œํ‚ฌ String

Return Value

์ œ๊ณต๋œ ๋ฌธ์ž์—ด์„ ์กฐํ•ฉํ•œ ์ƒˆ๋กœ์šด ๋ฌธ์ž์—ด

Description

์ƒˆ๋กœ์šด ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์›๋ณธ ๋ฌธ์ž์—ด ๋ณ€ํ˜•๋˜๊ฑฐ๋‚˜ ์˜ํ–ฅ์„ ๋ผ์น˜์ง€ ์•Š๋Š”๋‹ค. ๋ฌธ์ž์—ด์€ ๋ถˆ๋ณ€ ๊ฐ’ Immutable.. ์ธ์ž์˜ ๊ฐ’์˜ type string์ด ์•„๋‹ˆ๋ฉด ์—ฐ๊ฒฐ์‹œํ‚ค๊ธฐ ์ „์˜ ๋ฌธ์ž์—ด์„ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

Performance

concat() ๋ฉ”์†Œ๋“œ ๋Œ€์‹ ์— ํ• ๋‹น ์—ฐ์‚ฐ์ž ("+", "+=")๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์ด ๊ฐ•๋ ฅํžˆ ๊ถŒ์žฅํ•œ๋‹ค.

ํ• ๋‹น ์—ฐ์‚ฐ์ž๊ฐ€ ๋” ๋น ๋ฅด๋‹ค.

Examples

Last updated

Was this helpful?