str.concat(string2, string3[, ..., stringN])
- 원본 문자열과 결과 문자열의 변형은 서로에게 영향을 미치지 않습니다.
- 인수가 문자열이 아니면 계산 전에 문자열로 변환합니다.
const str1 = 'Hello'; const str2 = 'World'; console.log(str1.concat(' ', str2)); // 'Hello', ' ', 'World'를 이어붙임 // expected output: "Hello World" console.log(str2.concat(', ', str1)); // expected output: "World, Hello"
성능
할당연산자(+, +=)가 몇배는 더 빠르므로 쓰지마라.