score:1
The problem is very simple. Overview.countryData[index]
is not defined for the value of index
and its value in the if
condition is undefined
.
But undefined
is not the same thing as 'undefined'
.
undefined
is the value of a missing key in an object or array, the value of a variable that has be unset or not yet set.
'undefined'
is a string literal.
No matter how do you compare them (using ==
or ===
), undefined
and 'undefined'
are never equal.
Because of that, the if
condition is always true
and it is always taken. But the code in the if
branch assumes that Overview.countryData[index]
exists (is defined, is not undefined
).
The correct test condition is:
if (Overview.countryData[index] != undefined)
You can use, as well:
if (Overview.countryData[index])
because undefined
is always evaluated as false
in boolean context. The code is more clear this way.
Source: stackoverflow.com
Related Query
- it seems me that javascript If...Else works strangely
- what means ${demo.css} in example files of highcharts ? That piece of code seems to be literal
- tool that shows javascript errors in code
- Decimals on yAxis are not being displayed, even if that same code works on highcharts jsfiddle
- Optimize JavaScript DrillDown code
- Dynamic PDF from html that contains Javascript
- Code works on fiddle but not when I do /show
- JavaScript code inside TypeScript file .ts not working
- javascript variable not works in Highchart
- c# WPF Webbrowser with Highchart, Javascript from external source not working "An error has occurred in the script on this page"
- Javascript chart component that can handle annotated news headlines
- passing formatting JavaScript code to HighCharts with JSON
- Embed javascript code in a django template
- Returning javascript in an ASP.NET ajax postback fails, but works fine on initial page load
- Tooltip in Javascript with if else condition
- HTML Content to Javascript Code
- Strange character in the Highstock source code
- What's the code in Highcharts such that the bars (columns) in the same group use the same color?
- Repeating Javascript Code
- Converted PHP code that built an array to JS and now highcharts doesn't work - what did I do wrong?
- Assigning JSON value to a Variable that Resides Outside JavaScript Function
- Error: Data source must be a URL for refresh | console error | javascript | Highcharts
- Javascript Code not running in Wordpress Pages
- How to make Javascript file use variable that was sent to Pug view
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- Use django variable (array of elements from sqlite3 database) inside javascript embedded code
- Looking for a program, that supports DOM funtions and run javascript in linux server, just like a browser but without User Interface
- Highcharts code with same set of code/data works in PHP but does not work in JSfiddle
- Javascript relative time 24 hours ago etc as time
- Highchart series update in javascript
More Query from same tag
- Is it possible create a Highstock chart using TWO PANES and MULTIPLE SERIES in a pane
- Is it possible to have different colored graphs in a single series in HighCharts?
- Export Table and Chart In PDF In HIGHCHART with ANGULAR
- Highcharts & Angularjs: update chart from $broadcast in the main controller doesn't update the chart like a $watch would in the chart's controller
- HighCharts - do not crop series line on max value
- Is there a way to configure columns in highchart to have zero pointPadding AND a maxPointWidth?
- Highstock shared tooltip multiple series - show data for line when not on point
- Highcharts-vue - Calling my own tooltip label formatter function
- Highchart Spline with inverted axis categorie text left align
- Angular Highcharts Reading from multi objects elements
- How to populate a Highcharts axis with string formatted data from a PHP array
- Highcharts Density Dot Map Support?
- HighCharts Export Server not rendering series marker symbols consistently
- how to pass values to tooltip which not in x and y axis in highcharts
- Using HighCharts with LARAVEL
- highchart stacked bar plotting data doesn't work by javascript
- Highcharts clickable column to open another page on same site
- Style grouped categories
- Different colors for positive/negative parts of column
- Adding narrative to pie chart (highcharts)
- Highcharts showing in some pages, not showing in root pages
- Highcharts saying undefined is not a function when trying to add a new chart
- Highchart GMT and one hour offset
- Spline chart does not overlap with arearange chart (Highcharts framework)
- Highcharts legends are overlapping when i change language to arabic
- Show multiple Tooltips in highcharts on overlapping points
- How can i disable the autocomplete of highstocks
- How I can change the axis both side in y axis?
- Place Highstock inside a SVG
- how to display Highcharts from database in C# .Net