Skip to content
Malexion edited this page Oct 31, 2016 · 1 revision

__.switch(value, hash, [default])

  • value Value to use on the hash object.
  • hash Object whos keys are used like switch statement cases.
  • [default] [Optional] Default value returned if nothing comes of the hash[value].

Examples

var result = __.switch(2, {
   1: 'hello',
   2: x => { return 'Hello World' },
   3: 'world'
}, null);

console.log(result);