Permalink
Browse files

Merge pull request #48 from arturopuente/framework-free

Uses native Array#map when available
  • Loading branch information...
xenda committed Jun 14, 2012
2 parents b19f308 + f99bd30 commit 3f8225dbc87f91afeaf4e335bd8f88af48cc9fc7
Showing with 10 additions and 6 deletions.
  1. +10 −6 gmaps.js
View
@@ -1134,13 +1134,17 @@ var extend_object = function(obj, new_obj) {
};
var array_map = function(array, callback) {
- var array_return = [];
+ if (Array.prototype.map && array.map === Array.prototype.map) {
+ return array.map(callback);
+ } else {
+ var array_return = [];
- var array_length = array.length;
+ var array_length = array.length;
- for(var i = 0; i < array_length; i++) {
- array_return.push(callback(array[i]));
- }
+ for(var i = 0; i < array_length; i++) {
+ array_return.push(callback(array[i]));
+ }
- return array_return;
+ return array_return;
+ }
}

0 comments on commit 3f8225d

Please sign in to comment.