[javascript] setTimeout, setInterval 파라미터 버그

in #javascript5 years ago (edited)
  • IE 9 이하로 setTimeout 선언시에 파라미터 값을 던지면 값이 undefined 로 넘어온다.

1. 버그 상황

setTimeout( fncName, duration, param1, param2 );

2. 대응 코드

  • 아래와 같이 익명함수로 하나 감싸서 던지거나 새로운 함수를 지정하여 던져서 실행하면 문제가 없다.
setTimeout(function() {
  fncName( param1, param2 );
}, duration);

3. 참고

Sort:  

Congratulations @nonoll!
Your post was mentioned in the Steem Hit Parade for newcomers in the following category:

  • Pending payout - Ranked 3 with $ 3,25

Congratulations @nonoll! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You got your First payout

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - A better rich list comparator
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @nonoll! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Valentine's day challenge - Give a badge to your beloved!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!