Converting enums to array of values (Putting all JSON values in an array)
Simple solution (ES6)
You can use Object.values
like this:
var valueArray = Object.values(types);
I would convert the map into an array and store it as types.all
.You can create a method that does it automatically:
function makeEnum(enumObject){ var all = []; for(var key in enumObject){ all.push(enumObject[key]); } enumObject.all = all;}
var types = { "WHITE" : 0, "BLACK" : 1}var typeArray = Object.keys(types).map(function(type) { return types[type];});//typeArray [0,1]model.validate("typesColumn", typeArray);