Hello Guys Today i will discuss which loop among "for","while" and "do-while" is faster?
I am comparing only these 3 loops in this post.
Let's get...
For further actions, you may consider blocking this person and/or reporting abuse
Next time you want to do timings in JS, instead of manually calculating the time, just use
console.time(label)
and it's companionconsole.timeEnd(label)
.See docs: developer.mozilla.org/en-US/docs/W...
Thank you i will use it
Which JS interpreter are you using? Is it possible it's running a JIT optimize step as part of the first run that is reflected in the
subsequent runs?
I am using node js for running these
Ok, so V8. So suspect the answer to your question:
is probably the JIT compiler/optimizer:
blog.logrocket.com/how-javascript-...
Thank i will read this
Hey, Can you test the below For loop? I guess it will give you slightly better performance.
The code is not correct can you please write it correctly
I'm not sure where you're struggling. The error message is quite telling, in that all that's missing is:
Then the snippet runs. Though my quick look over it seems to make it benchmark slower than the
for
-scoped version, which is a bit surprising.Yeah got it
Speed and performance really become a serious requirement when you are trying to find the best data structure for your application. Especially when it has a lot of users.
Yes it is and i performed this test because I wanted to see that all these loops are equal or have some sort of difference