6

I have the following code in javascript

console.log(dates)
domain = Object.entries(dates)
console.log(domain)

where:

dates = {
    "0": "2003-02-01T05:00:00.000Z",
    "1": "2003-03-01T05:00:00.000Z",
    "2": "2003-04-01T05:00:00.000Z"
}

Strangely,

domain = [
    ["0", "2003-02-01T05:00:00.000Z"],
    ["1", "2003-03-01T05:00:00.000Z"],
    ["2","2003-04-01T05:00:00.000Z"],
    "0",
    "1",
    "2"
]

const dates = {
    "0": "2003-02-01T05:00:00.000Z",
    "1": "2003-03-01T05:00:00.000Z",
    "2": "2003-04-01T05:00:00.000Z"
};
    
const domain = Object.entries(dates);
console.log(domain);
.as-console-wrapper { max-height: 100% !important; top: 0; }

I would like to know what is going on. I get the same results (a list of numbers of the same length than the initial array appended to the end) when I use keys and values too.

Help is much appreciated.

EDIT:

There is one issue marked at console.log(domain). It reads:

Audit usage of navigator.userAgent, navigator.appVersion, and navigator.platform

A page or script is accessing at least one of navigator.userAgent, navigator.appVersion, and navigator.platform. Starting in Chrome 101, the amount of information available in the User Agent string will be reduced.
To fix this issue, replace the usage of navigator.userAgent, navigator.appVersion, and navigator.platform with feature detection, progressive enhancement, or migrate to navigator.userAgentData.
Note that for performance reasons, only the first access to one of the properties is shown.

AFFECTED RESOURCES
1 source
popper.min.js:1

Do you think this is the source of the issue? If so what can I do?

Ele
  • 33,468
  • 7
  • 37
  • 75
mm_
  • 1,566
  • 2
  • 18
  • 37
  • 2
    Most likely the reason is [Is Chrome's JavaScript console lazy about evaluating arrays?](https://stackoverflow.com/q/4057440) because you have some code later that adds `"1"`, `"2"` and `"3"` to the array. The code you've shown here [works just fine](https://jsbin.com/hivenolefe/edit?js,console) – VLAZ Oct 27 '21 at 04:33
  • Let me check in firefox. – mm_ Oct 27 '21 at 04:35
  • weird. try in jsfiddle or codesnippet here – cmgchess Oct 27 '21 at 04:35
  • @mm_ FF also has the same behaviour of the console. – VLAZ Oct 27 '21 at 04:36
  • What if FF? FireFox? Yes, same. – mm_ Oct 27 '21 at 04:41
  • I try with your data, the result is ok Array [Array ["0", "2003-02-01T05:00:00.000Z"],...]. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries – Huy Nguyen Oct 27 '21 at 04:41
  • The dates are Date objects. Do you think that has anything to do with my problem? – mm_ Oct 27 '21 at 04:49
  • I’m voting to close this question because it is belong to chrome community – xdeepakv Dec 12 '21 at 04:35
  • The thing here is the input values. Here you are just pasting the input values as string. try to see what type is that by typeof() and check. For strings it will work fine – Vikas Acharya Jan 18 '22 at 14:42
  • @mm_ I am not sure if i understand the question correctly but I just checked in jsfiddle : https://jsfiddle.net/dwso9ejh/ and it is working fine here. – Debug Diva Feb 03 '22 at 12:05

0 Answers0