// old way if (type == 'foo' || type == 'bar') { ... } // better if (/^(foo|bar)$/.test(type)) { ... } // object literal lookup if (({ foo : 1, bar : 1 })[type]) { ... }
Copyright Rebecca Murphey, released under the Creative Commons Attribution-Share Alike 3.0 United States license.