+ 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

14th Feb 2018, 1:52 PM
Yu Minwoo
Yu Minwoo - avatar
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
14th Feb 2018, 2:03 PM
jay
jay - avatar
+ 2
Thank you
14th Feb 2018, 2:56 PM
Yu Minwoo
Yu Minwoo - avatar