Skip to main content
Inspiring
October 23, 2012
Answered

Can an array have two separate values through the use of "or"?

  • October 23, 2012
  • 2 replies
  • 597 views

I was wondering if it's possible for an array to have two different values.  In other words, something such as this:

var array = new Array(obj1, obj2, obj3) || (obj4, obj5, obj6);

I know the above code isn't correct, but is it possible for an array to have two different set of values?

This topic has been closed for replies.
Correct answer Ned Murphy

I don't think there is any whay to have it be conditional, but you can have a mutlidimensional array:

var array = new Array([obj1, obj2, obj3], [obj4, obj5, obj6]);

and then make the choice of one set or the other.

2 replies

Ned Murphy
Ned MurphyCorrect answer
Legend
October 23, 2012

I don't think there is any whay to have it be conditional, but you can have a mutlidimensional array:

var array = new Array([obj1, obj2, obj3], [obj4, obj5, obj6]);

and then make the choice of one set or the other.

kglad
Community Expert
Community Expert
October 23, 2012

not at the same time unless you have a quantum computer.