1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

add Array::map polyfill to compatible with es4

This commit is contained in:
Alexander Lukin 2016-06-16 13:38:25 +03:00
parent ceb98fd099
commit b51a35e006

View File

@ -418,6 +418,23 @@
return version.split(".").length; return version.split(".").length;
} }
/**
* Array::map polyfill
* @param {Array} arr
* @param {Function} iterator
* @return {Array}
*/
function map(arr, iterator) {
var result = [], i;
if (Array.prototype.map) {
return Array.prototype.map.call(arr, iterator);
}
for (i = 0; i < arr.length; i++) {
result = iterator(arr[i]);
}
return result;
}
/** /**
* Calculate browser version weight * Calculate browser version weight
* @see http://jsbin.com/vohahaciku/1/edit?js,console * @see http://jsbin.com/vohahaciku/1/edit?js,console