5

I know it's might be silly. But at least, I got this feeling many times.

Sometimes I'm trying to fix some bugs, mostly with Angular's $http request, callbacks or even with Node promise.

When things go wrong, I try to put some console.log to detect the code flow, and from that moment, (mostly) the bugs will disappear! It's not only happened to me.

So I think, somehow, console.log affect to the performance (make the program run a bit slower), and then, it makes the bugs gone!

enter image description here

I know I'm not the only one think this. Do you think it's possible? Or have you also meet this kind of issue before? please discuss!

Huy Tran
  • 815
  • 1
  • 12
  • 22

2 Answers2

5

Certainly!

This is especially noticeable when logging many items in a loop, or when logging complex objects. Calls to console.log can be time consuming, and consequently, that delay can resolve some of your race conditions.

David Hedlund
  • 128,221
  • 31
  • 203
  • 222
  • yeah! thanks for pointing out, I got the feeling but not sure what to describe it, race condition is a good word to describe my problem! – Huy Tran Feb 03 '16 at 07:11
4

JavaScript usually considered as single threaded. that why it is most likely any extra code row will effect the performance.

here is a great answer why it is not sure that it is :(

Is javascript guaranteed to be single-threaded?

Good Luck!

Community
  • 1
  • 1
TERMIN
  • 824
  • 8
  • 18
  • ah, yes, I forgot about that, it's single threaded so it might be slow for sure when we do logging. thank you so much! – Huy Tran Feb 03 '16 at 07:10