const firstLine = " Call me Ishmael "; //양 끝과 중간에 빈칸 있음
console.log(firstLine.replace(/ /g, ""));
결과
CallmeIshmael
const firstLine = " Call me Ishmael ";
console.log(firstLine);
결과
Call me Ishmael
trim()은 문자열 앞뒤의 공백만 메꿔줍니다.
console.log(firstLine.trim());
결과
Call me Ishmael
replace는 특정 문자를 특정 값으로 변환해 주는데, 하나의 문자만 변경됩니다.
console.log(firstLine.replace(" ", ""));
결과
Call me Ishmael