mirror of
https://github.com/wassname/Mostly-Harmless.git
synced 2026-09-10 11:40:59 +08:00
Added objConvert
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user