Community

Javascript 반복문 성능

프로그래밍 문제를 풀다가 while 문을 사용하면 시간 초과가 나고, for 문을 사용하니 성공하는 경우를 발견했습니다. 평소 while 문이 사용하기에 편해서 자주 사용하곤 했는데 배열의 크기가 크거나 연산이 오래 걸리는 문제는 for 문을 사용해야 되겠어요. 배열의 크기가 1000000(백만)일 때 연산 속도 for Chrome Output: 3ms Firefox Output: 2ms while Chrome Output: 6ms Firefox Output: 37ms 관련자료 https://blog.bitsrc.io/measuring-performance-of-different-javascript-loop-types-c0e9b1d193ed

알림

알림이 없습니다