+ 2
Java script 'if vs switch' Who is the fastest?
Java script 'if vs switch' Who is the fastest? I want know Who is faster When if faster than switch? It's JS
2 Answers
+ 8
Switch generally outperforms complex nested if statements.
For simple non nested if statements the performance gain would be negligible.
You can test this for yourself here:
https://www.nczonline.net/experiments/javascript/performance/conditional-branching
And read more here:
http://archive.oreilly.com/pub/a/server-administration/excerpts/even-faster-websites/writing-efficient-javascript.html
+ 2
Thank you