문자관련 메서드정리 toUpperCase() 메서드 - 문자열의 모든 글자를 대문자로 바꿔주는 메서드이다. const str = "hi my name is jjangu" str.toUpperCase() //"HI MY NAME IS JJANGU" toLowerCase() 메서드 - 문자열의 모든 글자를 소문자로 바꿔주는 메서드이다. const str = "HI MY NAME IS JJANGU" str.toLowerCase() //"hi my name is jjangu" length() 메서드 - 변수안의 글자 갯수를 나타내는 메서드이다. (띄어쓰기포함) const str = "hi my name is jjangu" str.length //20 charAt() 메서드 - 변수안 문자열의 위치를 찾아주는 메..
Array.prototype.reduce() - reduce() 메서드는 배열의 각 요소에 대해 주어진 함수를 실행하고 하나의 결과값(Number)를 반환한다. 기본구문 .reduce(function(accumulator, currentValue, currentIndex, array) { return accumulator + currentValue; }); callback: 배열의 각 요소에대해 실행할 함수 accmulator: 콜백의 반환값을 누적한다 currentValue: 현재 처리할 요소 currentIndex: 현재 처리할 요소의 인덱스 기본값:0 (생략가능) array: reduce()를 호출한 배열 (생략가능) intialValue: 첫번째 인수에 제공하는 값 초기값이 없다면 배열의 첫번째 ..
Array.prototype.filter() - filter()메서드는 주어진 함수의 테스트를 통과하는 모든 요소를 모아 새로운 배열로 반환하는 배열메서드이다. - filter의 조건을 충족하는 요소가 없을때는 빈 배열을 반환한다. - 배열뿐만 아니라 객체에서도 사용이 가능하다. - map(),reduce() 와 더불어 객체에서 가장 많이 사용되는 메서드이다. 기본구문 arr.filter(callback(요소[, 인덱스[, 배열]])[, thisArg]) const arr = [1,2,3,4,5,6,7,8,9] const arr1 = arr.filter(e => e > 6) console.log(arr1) //[ 7, 8, 9 ] 배열 arr를 filter()메서드를 사용해 6보다 큰 요소들을 걸러내어 ..