Skip to content

Instantly share code, notes, and snippets.

@st98
Created January 8, 2014 17:08
Show Gist options
  • Select an option

  • Save st98/8320341 to your computer and use it in GitHub Desktop.

Select an option

Save st98/8320341 to your computer and use it in GitHub Desktop.
JavaScriptで列挙型みたいなもの。
(function () {
var slice = [].slice;
var Enum = function () {
var args = slice.call(arguments);
var count, len;
var result = {};
for (count = 0, len = args.length; count < len; count += 1) {
result[args[count]] = count;
}
return result;
};
this.Enum = Enum;
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment