728x90
concat() 란?
concat()는 둘 이상의 문자열을 결합하여, 새로운 문자열을 반환해주는 메서드입니다.
const str1 = "cat"
const currentStr1 = str1.concat("sleep"); //catsleep
const currentStr2 = str1.concat(" ","sleep"); //cat sleep
const currentStr3 = str1.concat(" ",["so","cute"]); //cat so,cute
"문자열".concat(문자열)
"문자열".concat(문자열,문자열...)
const str1 = "javascript";
const currentStr1 = str1.concat("reference") //javascriptreference
const currentStr2 = str1.concat(" ", "reference") //javascript reference
const currentStr3 = str1.concat(",", "reference") //javascript,reference
const currentStr4 = str1.concat(", ", "reference", ", " , "book") //javascript, reference, book
const currentStr5 = str1.concat(" ",[ "refer", "book"]) //javascript refer,book //배열은 (,)로 나옴
728x90
'Javascript' 카테고리의 다른 글
padStart() / padEnd() (4) | 2022.08.17 |
---|---|
repeat() (4) | 2022.08.17 |
replace() / replaceAll() (1) | 2022.08.17 |
split() (4) | 2022.08.17 |
소문자&대문자 | 공백 (2) | 2022.08.17 |
댓글