Last active
October 9, 2015 12:45
-
-
Save MikeFielden/04dbbff34270b683f0c5 to your computer and use it in GitHub Desktop.
Enum-like structure in es2015
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shapeType = { | |
triangle: new Symbol() | |
}; | |
// Demo func | |
function getArea(shape, options) { | |
var area = 0; | |
switch (shape) { | |
case shapeType.triangle: | |
area = .5 * options.w * options.h; | |
break; | |
} | |
return area; | |
} | |
getArea(shapeType.triangle, {w: 100, h: 50}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment