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
Post a Comment