ES6 스터디 정리 : trim, trimStart, trimEnd

Llux lux·2022년 5월 20일
0

ES6 스터디

목록 보기
18/21

trim

문자열의 앞부분과 뒷부분의 빈 문자열을 모두 제거해 준다.

let test = "       hello           ";
test = test.trim();
console.log(tst);
//hello 라는 결과가 출력된다.

trimStart

문자열의 앞 부분 빈 문자열을 제거해 준다.

let test = "       hello           ";
test = test.trimStart();
console.log(tst);
//"hello           " 라는 결과가 출력된다.

trimEnd

문자열의 뒷 부분 빈 문자열을 제거해 준다.

let test = "       hello           ";
test = test.trimStart();
console.log(tst);
//"       hello" 라는 결과가 출력된다.
profile
하하하

0개의 댓글