diff --git a/js/common.js b/js/common.js index fba45b2..ca4235a 100644 --- a/js/common.js +++ b/js/common.js @@ -20,6 +20,21 @@ function MHUtils() { return true; } +/** + * Convert an array to an object with properties of the array each having empty values, for use in "in" statements. + * @alias MHUtils.objConvert(arr) + * @param {Array} arr The array to be converted + * @return {Object} Returns the object + * @method + */ +MHUtils.prototype.objConvert = function (arr) { + var obj = {}; + for (var i = 0; i < arr.length; i++) { + obj[arr[i]]=''; + } + return obj; +}; + /** * Escape special RegExp characters. * @alias MHUtils.regexEscape(str)