Reputation: 2787
The following alerts nothing. I assume everyone can see what I'm trying to accomplish. Does anyone know what's going wrong?
var myarray = ['foo', 'bar'];
switch (myarray) {
case ['foo', 'bar']:
alert('foobar');
break;
case ['foo', 'foo']:
alert('foofoo');
break;
}
Upvotes: 0
Views: 80
Reputation: 78690
Because ['foo', 'bar']
does not equal another instance of ['foo', 'bar']
. They are two distinct objects which happen to contain the same information.
Upvotes: 8