Permalink
Browse files

Modified advancedConcatenator

  • Loading branch information...
ialcazar committed Aug 15, 2011
1 parent 6e27a59 commit 0599bde181b0bf297d37d29e9df18a9a67f9d682
Showing with 10 additions and 6 deletions.
  1. +10 −6 arrays/concatenator/advancedConcatenator.js
@@ -1,7 +1,3 @@
-Object.prototype.isArray = function(){
- return (this && typeof(this.push) === 'function' && typeof(this.pop) === 'function' && typeof(this.shift) === 'function');
-}
-
var concatenate = (function(){
//Private properties
var params;
@@ -24,16 +20,24 @@ var concatenate = (function(){
function isLastParam(p1){
return (p1<params.length-1);
}
+
+ function isArray(arr){
+ if(!Array.isArray){
+ Object.prototype.isArray = function(){
+ return Object.prototype.toString.call(arg) === '[object Array]';
+ }
+ }
+
+ }
//Public
return function (parameters){
var result = "";
- params = parameters && parameters.isArray()?parameters:[ ];
+ params = parameters && Array.isArray(parameters)?parameters:[ ];
if(hasElements()){
result = createString();
}
return result;
}
})();
-

0 comments on commit 0599bde

Please sign in to comment.