파게로그

array 본문

콤퓨타 왕기초/JS

array

파게 2020. 10. 15. 10:32
const arr1 = [];

// Array.prototype.filter()
// 지정한 콜백의 반환 결과가 true인 요소만 모은 새로운 배열을 반환합니다.
const arr2 = arr1.filter(foo1);
const arr3 = arr1.filter(function(element) {
	// ...
    }); // lambda 함수처럼 이름 없는 함수 사용 가능

// Array.prototype.forEach()
// 배열의 각각의 요소에 대해 콜백을 호출합니다.
arr1.forEach(foo2);
arr1.forEach(function(element) {
	// ...
    });

 

Array에 적용할 수 있는 메서드

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array

'콤퓨타 왕기초 > JS' 카테고리의 다른 글

JSON 다루기  (0) 2020.10.15
DOM에서 element 생성 또는 제거  (0) 2020.10.15
event, event handlers (2)  (0) 2020.10.12
event, even handlers (1)  (0) 2020.10.12
DOM 기초  (0) 2020.10.12
Comments