-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Misleading console output for arrays with undefined #1651
Comments
Your assumption isn't really valid. Perhaps this kind of array should be printed like a dictionary, but it can be misleading as well. |
What do you prefer? |
I can see why the output would be misleading.
|
And this is why we don't use delete for arrays, we us Array.slice() |
deleting items from array lead to misleading results ;-) |
That's because deleting is improper on an array. :P Sent from my shiny glass rectangle On Sep 5, 2011, at 12:43 AM, medikooreply@reply.github.com wrote:
|
True, but there should be some way of printing this kinds of arrays. |
@mmalecki this would be misleading as well, I would say it'll be best to display it with all properties named then: |
@medikoo These are not string indexes, so it should be: |
I think a dictionary misleads people into thinking it's a dictionary. |
Also +1 on @bnoordhuis solution |
In both cases I've originally mentioned, it holds that:
For me, this looks like a sufficient reason to consider |
Currently when we declare named property on array, we have output like following:
That is great. So I guess best would be to do same for "disconnected" indexes:
|
Either way it's icky. On Sep 6, 2011, at 1:14 AM, medikooreply@reply.github.com wrote:
|
How about c6fe2b3? (This is a workaround for a workaround...)
But... unfortunately:
(´・ω・`) |
I approve of that behavior. On Sep 6, 2011, at 8:31 AM, koichikreply@reply.github.com wrote:
|
@koichik +1 |
@NuckChorris, @TooTallNate - Thanks. |
@koichik - LGTM but I think it's time we start breaking up that 200 line inspect function, it's getting unwieldy. |
@bnoordhuis - I agree. I will extract the anonymous function that is parameter of |
@bnoordhuis - I have just divided |
@koichik - Love it. There should be two newlines between functions but otherwise LGTM. |
Done. Thanks! |
Code:
var list1 = [1, undefined, 3]; var list2 = [1, 2, 3] delete list2[1] console.log(list1) console.log(list2) console.log(list1[1]) console.log(list2[1])
Output current:
[ 1, undefined, 3 ] [ 1, 3 ] undefined undefined
Output expected:
[ 1, undefined, 3 ] [ 1, undefined, 3 ] undefined undefined
The text was updated successfully, but these errors were encountered: