new Array(len) should not log as [undefind, ...]

Fixed Issue #12301694

Details

Created
Jun 10, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
  • Internet Explorer
  • Chrome
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

  1. open DevTool > Console
  2. evaluate "new Array(2)"
  3. log as "[undefined, undefined]"

Attachments

0 attachments

    Comments and activity

    • if we log new Array(2) as [undefined, undefined], It is easily confused with the actual [undefined, undefined].

      According to ECMAScript Spec, They’re different. There are no real undefineds in arrays constructed from new Array(len). For example, hasOwnProperty(0) will return false and iteration functions like map() would behave differently.

      [undefined, undefined].map(e => 1)  // [1, 1]
      new Array(2).map(e => 1)                  // [undefined, undefined]
      
      [undefined, undefined].hasOwnProperty(0) // true
      new Array(2).hasOwnProperty(0) // false
      

      As a comparison,
      Chrome log new Array(2) as (2) [undefined × 2]
      (Confusing, so there is also a issue)
      Safari log new Array(2) as just [] (2); (good)
      Firefox log new Array(2) as Array [ ]; (prefered)

    • Firefox log new Array(2) as Array [ \ ]
      (wish this time the \ escaped well)

      Why I’m Anonymous, weird…

    • Oh WTF…It’s buggy.

      Firefox log new Array(2) as Array [ 2 empty slots ]

    • Microsoft Edge Team

      Changed Assigned To to “Leo L.”

      Changed Assigned To from “Leo L.” to “Jeff F.”

      Changed Status to “Confirmed”

      Changed Status from “Confirmed” to “Fixed”

    You need to sign in to your Microsoft account to add a comment.

    Sign in