javascript - What is the best way to check if a bunch of variables are equal to some value? ie. are a,b,c,d are all equal to 3 -


i have few variables, , if of them equal 3, executing function. there performance hit, or there better way of doing this-

if (a === 3 && b === 3 && c === 3 && d === 3) {   //do } 

an obscure technique put variables array , check every.

if ([a, b, c, d].every(e => e === 3)) {     // code true } 

Comments

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

angular - Angular2 Router: Cannot find primary outlet to load 'HomeComponent' -

javascript - Why Selenium can't find an element that is graphically visible -