. :
var a;
function setStuff(x) {
if (a == x) { return; }
a = x;
}
setStuffCheck(0) ;
setStuffCheck('0');
console.log(a);
'0', 0.
setStuffCheck ===.
FireFox , . setStuffCheck, , , setStuff, , a, ( ), . 2%, , / , .
In any case, this also means that this small performance difference will depend on how often you expect to call the function with an argument equal to a.
However, the difference will be noticeable only when you make hundreds of millions of calls. If you don't have many calls, then don’t even bother and choose setStuff.
source
share