I have two expressions and I would like to know which one is better performance wise.
1 if(typeof a !== "undefined") {}
2 if(a) {}
(I am not sure how the second expression is called, so I refer to it as a naked if in the question title, feel free to correct me if you know the correct term for this)
I understand that the two expressions will result in being true under pretty much different conditions. I am not interested in this, I am only interested in performance.
Also, I understand that the performance difference may be considered as insignificant by someone. But still I am interested in it.
From my pov they both are readable well. For my case they both are applicable. Now I need to give a performance point to one of the two options. The point will decide which approach I am going to always use in the future in case both of them are appropriate.
Thank you.
Aucun commentaire:
Enregistrer un commentaire