Added objConvert

This commit is contained in:
Kerrick Long
2011-07-18 15:41:12 -05:00
parent 4b043a5cd5
commit e41b038c14
+15
View File
@@ -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)