What’s better? If:
function a(){};
then is it faster to process this
if(typeof a == "function"){func(arg);}
or this?
if(!(typeof a).search("f")){func(arg);}
I’m only asking this because in my opinion its easier to match first symbol of string than entire string, no? Interested in making sure.
Here is a jsPerf test http://jsperf.com/typeof-test12.
527,021,419operations per second.9,803,840operations per second.That is a huge margin (the first one is 54 times faster than the second on my computer).