문자열 관련 메서드
"word".length | 문자 길이 반환 |
"word".startsWith("string") | string값이 시작 값인지 검사 |
"word".endsWith("string") | string값이 끝 값인지 검사 |
"word".indexof("string") | string의 인덱스값 반환 , 없으면 -1 반환 |
"word".repeat(n) | 문자 n번 반복 |
"word".replace("문자", "바꿀문자") | 문자열 교체 |
"word".split("string") | string 기준으로 문자열을 쪼개어 배열로 반환 |
"word".slice(first,end) | 인덱스 first~ end-1 값까지 문자열 반환(인덱싱) |
"word".trim() | 앞 뒤 공백 제거 |
숫자 관련 메서드
value.toFixed(Number) | value의 소수점 Number째 자리 string 으로반환 |
배열 관련 메서드
array.push(value) | 배열 맨 뒤에 value 추가 |
array.splice(인덱스,0,value) | 지정 인덱스에 value 추가 |
array.splice(인덱스,count) | 지정 인덱스부터 count만큼 value 제거 |
array.splice(인덱스,count,value) | 지정 인덱스부터 count 까지 하나의 value로 교체 |
array.indexof("string") | 배열의 string이 위치한 index 반환, 없으면 -1 |
요소 관련 메서드
요소.style.스타일 속성 | 요소의 스타일 제어 |
요소.getAttribute("속성 이름") | 요소의 속성 추출 |
요소.setAttribute("변경할 속성", "새로운 속성값") | 속성 값 변경 |
요소.textContent | 요소의 텍스트 추출 |
요소.innerHTML | HTML 태그를 직접 조작 |
시간 관련 메서드
setTimeout(function(){ .... }, n) | n ms 후 함수 실행 |
clearTimeout() | setTimeout함수 종료 |
setInterval(function(){ .... },n) | n ms 마다 함수 실행 |
clearInterval() | setInterval함수 종료 |
boolean 관련 메서드
is__ 메서드 는 대부분 boolean형을 리턴함
Math 관련 메서드
Math.floor(Num) - Num의 소수점을 제거
Math.floor(Math.random() * Num) - 0부터 Num 까지 랜덤 정수를 반환
Lodash 관련 메서드
https://www.jsdelivr.com/package/npm/lodash
jsDelivr - A free, fast, and reliable CDN for Open Source
Supports npm, GitHub, WordPress, Deno, and more. Largest network and best performance among all CDNs. Serving more than 80 billion requests per month. Built for production use.
www.jsdelivr.com
_.sortBy(array,[key,..]) - 키를 기준으로 array를 정렬한 array를 반환
'JavaScript' 카테고리의 다른 글
함수 (0) | 2023.01.31 |
---|---|
web 입출력 (0) | 2023.01.30 |
JS의 기본개념 (0) | 2023.01.30 |
addEventListener (0) | 2022.08.06 |
객체 (0) | 2022.07.26 |