Index: src/js/array.js |
diff --git a/src/js/array.js b/src/js/array.js |
index 27109eabf9f013237bdf3fb12b89e02714f18bbb..1468d57c6cae52f3f4c307609d1c58a9517382f5 100644 |
--- a/src/js/array.js |
+++ b/src/js/array.js |
@@ -214,15 +214,19 @@ function Join(array, length, separator, convert) { |
// Non-empty separator case. |
// If the first element is a number then use the heuristic that the |
// remaining elements are also likely to be numbers. |
- if (!IS_NUMBER(array[0])) { |
- for (var i = 0; i < length; i++) { |
- var e = array[i]; |
+ var e = array[0]; |
+ if (!IS_NUMBER(e)) { |
+ if (!IS_STRING(e)) e = convert(e); |
+ elements[0] = e; |
+ for (var i = 1; i < length; i++) { |
+ e = array[i]; |
if (!IS_STRING(e)) e = convert(e); |
elements[i] = e; |
} |
} else { |
- for (var i = 0; i < length; i++) { |
- var e = array[i]; |
+ elements[0] = %_NumberToString(e); |
+ for (var i = 1; i < length; i++) { |
+ e = array[i]; |
if (IS_NUMBER(e)) { |
e = %_NumberToString(e); |
} else if (!IS_STRING(e)) { |