해당 Element의 클래스목록에 접근하는 간편한방법element.classList 메소드add : Element에 클래스를 추가 ex) element.classList.add('open')remove : Element에 클래스를 제거 ex) element.classList.remove('open')toggle : Element에 클래스가 존재하면 제거하고 없으면 추가 ex) element.classList.toggle('open') contain : Element에 클래스가 존재하는지 확인 ex) element.classList.contain('open')replace : Element에 클래스를 새로운 클래스로 교체 ex) element.classList.replace( 'open', 'close')..
Filter이름 그대로 특정조건에 만족하는값만 걸러내어 새로운 배열 생성ex) arr.filter( data => data.length > 6); Sort배열 안의 내용을 정렬시킨다 숫자는 오름차순 문자는 A,B,C,D 순객체배열을 정렬하는방법은 따로 글을 써뒀으니 참조ex) arr.sort(); map배열 안의 데이터마다 주어진 함수 처리를한후 새로운 배열 생성ex) arr.map( data => data * 2 ); forEach배열에 들어있는 데이터에 주어진함수를 실행한다ex) arr.forEach( data => console.log(data); ); reduce배열의 각 데이터에 리듀서함수를 실행한다 filter, map을 몰라도 reduce만으로 구현이 가능하다 사용하기에따라 유연하게 사용할수..
const inventors = [ { first: 'Albert', last: 'Einstein', year: 1879, passed: 1955 }, { first: 'Isaac', last: 'Newton', year: 1643, passed: 1727 }, { first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642 }, { first: 'Marie', last: 'Curie', year: 1867, passed: 1934 }, { first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630 }, { first: 'Nicolaus', last: 'Copernicus', year: 1473, passed:..
componentDidMount() { // processing response // 함수형은 딱 뭐하는지 한눈에 확인가능 console.log(fetch('')); // promise 객체를 리턴 const res = fetch('https://yts.am/api/v2/list_movies.json?sort_by=rating').then( response => // localhost:3000에 떄린거 fetch안에 인자가 비어있어서, 마지막으로 리턴해준값을 받을수있음 response.json()// body : ReadableStream으로 되어있는데 이걸 json으로 바꿔줘야함, cors : 같은데서 요청이 들어갈때 ).then( json => { console.log(json); this.setSt..