๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ

trim() / trimStart() / trimEnd()

by Youcodein 2022. 8. 17.
728x90
๋ฐ˜์‘ํ˜•

08. trim() / trimStart() / trimEnd()

๋ฌธ์ž์—ด์—์„œ ๊ณต๋ฐฑ์„ ์ œ๊ฑฐํ•˜๋Š” ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค.
๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ : ๋ณ€๊ฒฝ : trim() : ๋ฌธ์ž์—ด์˜ ์•ž๋’ค ๊ณต๋ฐฑ์„ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค : ๋ฐ˜ํ™˜(๋ฌธ์ž์—ด)
๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ : ๋ณ€๊ฒฝ : trimStart() : ๋ฌธ์ž์—ด์˜ ์•ž ๊ณต๋ฐฑ์„ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค : ๋ฐ˜ํ™˜(๋ฌธ์ž์—ด)
๋ฌธ์ž์—ด ๋ฉ”์„œ๋“œ : ๋ณ€๊ฒฝ : trimEnd() : ๋ฌธ์ž์—ด์˜ ๋’ค ๊ณต๋ฐฑ์„ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค : ๋ฐ˜ํ™˜(๋ฌธ์ž์—ด)

๋ฒˆํ˜ธ ๊ธฐ๋ณธ๊ฐ’ ๋ฉ”์„œ๋“œ ๋ฆฌํ„ด๊ฐ’
       
       
       
const str1 = "        javascript      ";
const currentStr1 = str1.trim();
document.querySelector(".sample08_N1").innerHTML = "1";
document.querySelector(".sample08_Q1").innerHTML = str1;
document.querySelector(".sample08_M1").innerHTML = "trim()";
document.querySelector(".sample08_P1").innerHTML = currentStr1;


const str2 = "        javascript      ";
const currentStr2 = str2.trimStart();
document.querySelector(".sample08_N2").innerHTML = "2";
document.querySelector(".sample08_Q2").innerHTML = str2;
document.querySelector(".sample08_M2").innerHTML = "trimStart()";
document.querySelector(".sample08_P2").innerHTML = currentStr2;

const str3 = "        javascript      ";
const currentStr3 = str3.trimEnd();
document.querySelector(".sample08_N3").innerHTML = "3";
document.querySelector(".sample08_Q3").innerHTML = str3;
document.querySelector(".sample08_M3").innerHTML = "trimEnd()";
document.querySelector(".sample08_P3").innerHTML = currentStr3;
728x90
๋ฐ˜์‘ํ˜•

'์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

replace() / replaceAll()  (4) 2022.08.17
split()  (4) 2022.08.17
๋ฌธ์ž์—ด ๊ฒฐํ•ฉ / ํ…œํ”Œ๋ฆฟ ๋ฌธ์ž์—ด  (3) 2022.08.17
toUpperCase() / toLowerCase()  (4) 2022.08.17
์ •๊ทœํ‘œํ˜„์‹  (4) 2022.08.17

๋Œ“๊ธ€