I have an array of many unique strings and I'd like, without looping if at all possible, to create a map object from it where the key for each element is a unique string and the value is defaulted to some arbitrary setting.
Is there a way I can do this in one line without looping? I.e. I want to go from
var colours = [ "Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet" ];
to
var colourMap = {
"Red": VAL,
"Orange": VAL,
"Yellow": VAL,
"Green": VAL,
"Blue": VAL,
"Indigo": VAL,
"Violet": VAL
};