-1

I have the problem that a simple JavaScript comparision is not working.

I have no idea why it jumps into line 12302 and sets showNoDataText = true. The condition should be false because the array length of 285 is less than 1. The values of boolValue is set correctly (=false).

But somehow it is not working. I have tried == and === for comparison and also 'if (boolValue) {...}' already. Does someone have an idea, please?

I use the newest version of Mozilla Firefox. It is also not working in Internet Explorer 11.

Remark: Please don't answer anymore, problem is solved already. Alexis provided the correct answer. Many thanks!

Problem is described here: Firefox debugger jumps from an if-block directly to an else-block

enter image description here

Community
  • 1
  • 1
Jana Weschenfelder
  • 840
  • 2
  • 8
  • 23
  • 1
    ShowNodatatext is maybe set to true before this test. And not change because of this test. Simply add `else { showNoDataText=false;}` – Alexis Jul 01 '16 at 09:49
  • If you have a code of 12302 rows, why insisting that showNoDataText = true is being defined here? It may be caused by other codes. –  Jul 01 '16 at 09:49
  • 2
    What happens when You try `if (points.length < 1)`? – Roman Hocke Jul 01 '16 at 09:51
  • Are you able to isolate the relevant code and post it here? That would be helpful. – U r s u s Jul 01 '16 at 09:51
  • 3
    You should try to keep your code as clean as possible... if you want to show "noDataTest" only when there are no points, so, you should do something like that: `var showNoDataText = points.length < 1;`...all the rest is superfluous... – Hitmands Jul 01 '16 at 09:52
  • I'm not sure if posting the whole code would be helpful here, it is in fact a modified HighCharts JavaScript code (HighStock.js) which is quite complex. The code is written by http://www.highcharts.com/stock/demo in the main, we are just using it with little modifications. *clean as possible is good, I would have to rewrite the whole JavaScript Code of HighCharts then. We use it as a template so that we don't have to write the whole code by ourselves. :P – Jana Weschenfelder Jul 01 '16 at 10:10
  • Thanks, in fact the solution of Alexis has helped me here. ShowNodatatext was set to true before this test by another function of HighCharts. Although I still don't understand why the debugger jumped inside of the wrong if condition. Now it jumps into both conditions if I execute the code (is also wrong), but it works correctly on the website now. Remark: I have checked the Firefox debugger against the Chrome debugger now. The Chrome debugger works correctly and jumps only inside one of both if conditions, so I think that the Firefox debugger has a bug here which was very misleading to me. – Jana Weschenfelder Jul 01 '16 at 10:30
  • 1
    Problem is descibed here: http://stackoverflow.com/questions/26419249/firefox-debugger-jumps-from-an-if-block-directly-to-an-else-block – Jana Weschenfelder Jul 01 '16 at 10:41

2 Answers2

1

Everythings working fine for me. I have tested in all browser.

There is two possibilities for this:

Either you changed value of boolValue in console just before execute code browser or You might need to restart your browser.

Here is my comparision which is working fine in all browser.

> https://jsfiddle.net/rietykity/67pf63o1/
Dee Nix
  • 170
  • 1
  • 13
  • 1
    I had tested it back then, it was not a code issue. It was indeed a Firefox bug which is described here. That bug had confused me, because I could not imagine how code was called inside the if and also the else block at the same(!) time. https://stackoverflow.com/questions/26419249/firefox-debugger-jumps-from-an-if-block-directly-to-an-else-block – Jana Weschenfelder Jun 27 '17 at 11:56
0

i am not sure what your problem exactly is, but as "Hitmands" commented, you can just do:

showNoDataText = points.length < 1;
Martin Ackermann
  • 884
  • 6
  • 15