728x90
01. toUpperCase()
toUpperCase()는 문자열을 대문자로 변경합니다.
번호 | 기본값 | 메서드 | 리턴값 |
---|---|---|---|
const str1 = "javascript";
const currentStr1 = str1.toUpperCase();
document.querySelector(".sample02_N1").innerHTML = "1";
document.querySelector(".sample02_Q1").innerHTML = "javascript";
document.querySelector(".sample02_M1").innerHTML = "toUpperCase()";
document.querySelector(".sample02_P1").innerHTML = currentStr1;
02. toLowerCase()
toLowerCase()는 문자열을 소문자로 변경합니다.
번호 | 기본값 | 메서드 | 리턴값 |
---|---|---|---|
const str2 = "JAVASCRIPT";
const currentStr2 = str2.toLowerCase();
document.querySelector(".sample02_N2").innerHTML = "1";
document.querySelector(".sample02_Q2").innerHTML = "JAVASCRIPT";
document.querySelector(".sample02_M2").innerHTML = "tolpperCase()";
document.querySelector(".sample02_P2").innerHTML = currentStr2;
03. trim() / trimStart() / trimEnd()
trim()은 문자열 앞뒤 공백을 제거한 것이고, trimStart()는 문자열 앞 공백, trimEnd()는 문자열 뒤 공백을 제거하는 메서드입니다.
번호 | 기본값 | 메서드 | 리턴값 |
---|---|---|---|
const str1 = " javascript ";
const currentStr = str.trim();
document.querySelector(".sample03_N1").innerHTML = "1";
document.querySelector(".sample03_Q1").innerHTML = str1;
document.querySelector(".sample03_M1").innerHTML = "trim()";
document.querySelector(".sample03_P1").innerHTML = currentStr;
const str2 = " javascript ";
const currentStr2 = str2.trimStart();
document.querySelector(".sample03_N2").innerHTML = "2";
document.querySelector(".sample03_Q2").innerHTML = str2;
document.querySelector(".sample03_M2").innerHTML = "trimStart()";
document.querySelector(".sample03_P2").innerHTML = currentStr2;
const str3 = " javascript ";
const currentStr3 = str3.trimEnd();
document.querySelector(".sample03_N3").innerHTML = "3";
document.querySelector(".sample03_Q3").innerHTML = str3;
document.querySelector(".sample03_M3").innerHTML = "trimEnd()";
document.querySelector(".sample03_P3").innerHTML = currentStr3;
728x90
반응형
'Javascript' 카테고리의 다른 글
[javascript]replace() / replaceAll() (3) | 2022.08.17 |
---|---|
[javascript]split() (2) | 2022.08.17 |
[javascript]문자열 결합 / 템플릿 문자열 (1) | 2022.08.17 |
[javascript]indexOf() / lastIndexOf() (2) | 2022.08.16 |
[javascript]slice() / substring() / substr() (2) | 2022.08.16 |
댓글