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:
parent
ceb98fd099
commit
b51a35e006
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user