@@ -207,7 +207,7 @@ function formatValue(ctx, value, recurseTimes) {
207
207
base = ' ' + value . toUTCString ( ) ;
208
208
}
209
209
210
- if ( keys . length === 0 ) {
210
+ if ( keys . length === 0 && ( ! array || value . length == 0 ) ) {
211
211
return braces [ 0 ] + base + braces [ 1 ] ;
212
212
}
213
213
@@ -221,9 +221,14 @@ function formatValue(ctx, value, recurseTimes) {
221
221
222
222
ctx . seen . push ( value ) ;
223
223
224
- var output = keys . map ( function ( key ) {
225
- return formatProperty ( ctx , value , recurseTimes , visibleKeys , key , array ) ;
226
- } ) ;
224
+ var output ;
225
+ if ( array ) {
226
+ output = formatArray ( ctx , value , recurseTimes , visibleKeys , keys ) ;
227
+ } else {
228
+ output = keys . map ( function ( key ) {
229
+ return formatProperty ( ctx , value , recurseTimes , visibleKeys , key , array ) ;
230
+ } ) ;
231
+ }
227
232
228
233
ctx . seen . pop ( ) ;
229
234
@@ -253,6 +258,25 @@ function formatPrimitive(ctx, value) {
253
258
}
254
259
}
255
260
261
+ function formatArray ( ctx , value , recurseTimes , visibleKeys , keys ) {
262
+ var output = [ ] ;
263
+ for ( var i = 0 , l = value . length ; i < l ; ++ i ) {
264
+ if ( Object . prototype . hasOwnProperty . call ( value , String ( i ) ) ) {
265
+ output . push ( formatProperty ( ctx , value , recurseTimes , visibleKeys ,
266
+ String ( i ) , true ) ) ;
267
+ } else {
268
+ output . push ( '' ) ;
269
+ }
270
+ }
271
+ keys . forEach ( function ( key ) {
272
+ if ( ! key . match ( / ^ \d + $ / ) ) {
273
+ output . push ( formatProperty ( ctx , value , recurseTimes , visibleKeys ,
274
+ key , true ) ) ;
275
+ }
276
+ } ) ;
277
+ return output ;
278
+ }
279
+
256
280
function formatProperty ( ctx , value , recurseTimes , visibleKeys , key , array ) {
257
281
var name , str ;
258
282
if ( value . __lookupGetter__ ) {
0 commit comments