Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- apple push notification service (apns) is changing
- (using password: YES)" when trying to connect
- bootstrap modal
- usb efi 시스템 파티션 삭제
- sha-2 root
- modsecurity 설치
- 파라미터 & 오류
- 윈도우 mod_security2
- mariadb upgrade
- mod_security2 설치
- postfix 설치
- 비밀번호정규식
- httpd.conf 보안 설정
- VS Code 서버설치
- 숫자 3자리(천단위) 마다 콤마 찍기
- html pdf 변환
- 비밀번호검증정규식
- 자바스크립트비밀번호검증
- php 배열제거
- 아파치 웹 서버의 정보 숨기기
- bootstrap
- group_concat 구분자
- 윈도우 환경 아파치 mod_security2 설치
- wsl2 우분투에 docker 설치
- php 이미지 url 검증 함수
- javascript
- thumbnail 클래스
- usb 삭제
- 유튜브 플레이 리스트 저장
- PHP 정규식 예제
Archives
- Today
- Total
투덜이 개발자
Promise.all , Promise.race 차이점 예제 본문
반응형
Promise.all
<script>
function timer(time) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve(time);
}, time)
});
}
console.time('Promise.all');
Promise.all([timer(1000), timer(2000), timer(3000)]).then(function (result) {
console.log('result', result);
console.timeEnd('Promise.all');
})
</script>
비동기 순으로 처리를 할때 제일 늦게 끝나는 timer(3000) 이 끝나야 작업이 끝난다.. 그러므로 결과는 3초
Promise.race
<script>
function timer(time) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve(time);
}, time)
});
}
console.time('Promise.race');
Promise.race([timer(1000), timer(2000), timer(3000)]).then(function (result) {
console.log('result', result);
console.timeEnd('Promise.race');
})
</script>
Promise.all 은 제일 처음 끝나는 timer(1000) 이 끝나면 작업이 끝난다.. 그러므로 결과는 1초
반응형
'Program Language > JavaScript & Jquery' 카테고리의 다른 글
| jquery datepicker 기간 설정 (0) | 2022.03.07 |
|---|---|
| [jQuery] 체크박스 전체 선택, 전체 해제, 모든 항목 체크 시 전체 선택 체크박스 선택되게 하기 (0) | 2022.02.14 |
| [JavaScript] 회원가입 정규식 유효성 검사 (0) | 2022.02.09 |
| (function() { })() 의 의미는? (0) | 2022.02.04 |
| [Javascript] 생년월일 (만)나이 계산, 생년월일 유효성 검사 (0) | 2022.02.04 |