Let's say I have an Array consist of Boolean.
myArray = [false,false,false]
And I will need to do different stuff according to every status.
ex :
[false,true,false], [false,false,true], [true,true,false], ...
and so on.
Usually this kind of operation is done by checking each individual element to see fit.
ex:
if(!myArray[0] && myArray[1] && !myArray[2]) do A
if(!myArray[0] && !myArray[1] && myArray[2]) do B
if(myArray[0] && myArray[1] && !myArray[2]) do C
...
Instead of doing that. I convert the array into String:
switch(JSON.stringify(myArray))
case : "[false,true,false]"
do A
break
case : "[false,false,true]"
do B
break
case : "[true,true,false]"
do C
break
......
Is this considered good practice? Is there any hidden error I might face with this method? Will this method increase readability ?