Slbox
Slbox

Reputation: 13138

Why does Chrome Devtools show variables defined within the current scope as undefined?

For example the variable mergedArray below.

My issue is that variables are often impossible to inspect even when defined within the current function.

I found other questions that ask something similar, but the answer in those questions relates to the variable being defined in a higher scope.

This issue is technically in Electron - but it uses what is essentially Chrome DevTools.

enter image description here

Upvotes: 10

Views: 1475

Answers (2)

Slbox
Slbox

Reputation: 13138

I don't have an answer for why this happens, but it can be remedied by temporarily adding a line in your code:

const variableUsuallyUnavailable = 1;

while(bool) {
  variableUsuallyUnavailable; // This will make it available in the debugger;
  // ... Your actual code
}

Not very convenient, but it's all I have to offer even after all these years.

Upvotes: 1

R...
R...

Reputation: 2620

try expanding the Scope pane (below or above Call Stack pane) and see what variables are listed under Local. it could be shown as a different name e.g.

enter image description here

this could be a result of minification

Upvotes: 2

Related Questions