자바스크립트에서 비동기를 처리한다(여러작업을 동시에 처리한다)? 지연이나 이슈가 발생하지 않도록하는 것을 말하며, 그 방식으로는 콜백, 프로토타입(promise), aync&await, fetch 등이 있다.
[비동기처리 방식(콜백, 프로토타입, 반환값)]
💡프로토타입*?
어떤 객체에 대해서도 재사용이 가능한 객체인 것
```jsx
const a = () => {
return new Promise((resolve) => {
setTimeout(() => {
console.log(1)
resolve()
}, 1000)
})
}
const b = () => {
console.log(2)
}
//a는 리턴타입이 promise 인스턴스라서 then 메소드 쓸 수 있지만, b는 안 됨.
a().then(()=>b)
b().then(()=>a) //cannot read properties of undefined(reading 'then')
```


movieList('harry potter')
.then(() => {
console.log('해리포터')
return movieList('avengers')
})
.then(() => {
console.log('어벤저스')
return movieList('home alone')
})
.then(() => {
console.log('나홀로집에')
})
const wrapping = async () => {
await movieList('harry potter')
// await console.log('아바타'); console은 promise 타입이 아니기에 await 쓸 수 없음
console.log('해리포터')
await movieList('avengers')
console.log('어벤저스')
await movieList('home alone')
console.log('나홀로집에')
}
//fetch 함수는 repl로 확인x -> html 문서 통해 실행 필요
//주의 : 함수 꼭 호출하기!!
wrapping()
npm 다운로드(npm install fullcalendar)
cnd 코드 입력
<script src='https://cdn.jsdelivr.net/npm/fullcalendar@6.1.9/index.global.min.js'></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: 'dayGridMonth'
});
calendar.render();
});
</script>
event 추가(일정) → 배열의 형식으로 더해짐
[
{
"title": "월간회의",
"start": "2023-11-01"
},
{
"title": "sqld 시험",
"start": "2023-11-18"
},
{
"title": "휴가",
"start": "2023-11-18",
"end":" 2023-11-20"
},
{
"groupId":"99",
"title": "업체회의",
"start": "2023-11-23T15:00:00"
},
{
"groupId":"888",
"title": "팀회의",
"start": "2023-11-28T10:00:00"
}
]
//일정에 대한 데이터셋 가져오기(배열, 계속 쌓여나감)
events:[
{
title: '월간회의',
start: '2023-11-01'
},
{
title: 'sqld 시험',
start: '2023-11-18'
},
{
title: '휴가',
start: '2023-11-18',
end: '2023-11-20'
},
{
groupId: 999,
title: '업체회의',
start: '2023-11-23T15:00:00',
},
{
groupId: 888,
title: '팀회의',
start: '2023-11-28T10:00:00',
}
]
});