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

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -