From e41b038c14a8b9dbde19e0f1030b71cb68de61f7 Mon Sep 17 00:00:00 2001 From: Kerrick Long Date: Mon, 18 Jul 2011 15:41:12 -0500 Subject: [PATCH] Added objConvert --- js/common.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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)