728x90
반응형
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
<script>
setTimeout(()=>{
console.log('첫번째 함수 끝');
setTimeout(()=>{
console.log('두번째 함수 끝');
setTimeout(()=>{
console.log('세번째 함수 끝');
},3000);
},2000);
},1000);
console.log('1');
setTimeout(() => { console.log('2')},1000);
console.log('3');
console.log('최종 delay:', print_delay(print, 2000));
print_immediateely(print);
function print_immediateely(func){
func('immediately');
}
function print_delay(func, time){
let delay = 'delay';
setTimeout(()=>{
console.log('변하기 전 delay:', delay)
delay = 30000;
console.log('변한 후 delay:', delay)
}, time);
return delay;
}
function print(massage) {
console.log(massage, '함수실행');
}
try{
setTimeout(()=>{
throw new Error('에러났당');
},3000);
//set
}catch(e){
console.log(e)
console.log('에러났네..')
}
</script>
728x90
반응형