본문 바로가기

전체 글330

filter filter [immutable] - 불변 arr.filter(callback(element[, index[, array]])[, thisArg]) 해당 element가 필터 조건에 맞는지 검사 callback 함수에는 리턴값이 필요 true일 경우 필터 조건에 통과 매개변수 callback 각 요소를 시험할 함수. true를 반환하면 요소를 유지하고 false를 반환하면 버립니다 element 처리할 현재 요소 index 처리할 현재 요소의 인덱스 array Optionalfilter를 호출한 배열 thisArg callback을 실행할 때 this로 사용하는 값 리턴 값 테스트를 통과한 요소로 이루어진 새로운 배열. 어떤 요소도 테스트를 통과하지 못했으면 빈 배열을 반환 filter 실행 let us.. 2020. 6. 20.
map map [immutable] - 불변 arr.map(callback(currentValue[, index[, array]])[, thisArg]) callback 함수에는 리턴값이 필요 해당 내용이 새로운 배열의 element가 됨 map 매개변수 callback 새로운 배열 요소를 생성하는 함수 currentValue 처리할 현재 요소 index 처리할 현재 요소의 인덱스 array map()을 호출한 배열 thisArg callback을 실행할 때 this로 사용되는 값 리턴 값 배열의 각 요소에 대해 실행한 callback의 결과를 모은 새로운 배열 map 실행 let arr = ['Security', 'Info', 'World']; function tiStory(curr) { return curr.. 2020. 6. 20.
for Each for Each [immutable] - 불변 arr.forEach(callback(currentvalue[, index[, array]])[, thisArg]) 배열의 길이만큼 반복 실행 인자로 전달되며, 실행 여부를 해당 함수가 결정하는 형태의 함수를 callback for Each 매개변수 callback 각 요소에 대해 실행할 함수 currentValue 처리할 현재 요소 index 처리할 현재 요소의 인덱스 array forEach()를 호출한 배열 thisArg callback을 실행할 때 this로 사용할 값 리턴 값 undefined for Each 실행 let arr = ['Security', 'Info', 'World']; arr.forEach(function(curr, index, a.. 2020. 6. 20.
객체 객체 (Object) 주소록에 주로 사용 let user = { firstName : 'Lee', lastName : 'Sangho', email : 'jesussangho@gmail.com', city : 'Seoul', phone : '010-0000-0000' }; firstName : 키(key) 'Lee' : 값(value) 객체는 키와 값 쌍(key-value pair)으로 이루어져 있음 Dot notaion (object.key) let user = { firstName : 'Lee', lastName : 'Sangho', email : 'jesussangho@gmail.com', city : 'Seoul', phone : '010-0000-0000' }; /*=================.. 2020. 6. 18.