Tuesday, 18 April 2017

_.indexOf doesn't work as expected

I have the following code snippet:

const summerIndex = _.indexOf(model.xAxisLabels, monthLabel);

When I debug the code, model.xAxisLabels contains

Array[12]

0 :"Mar 2016"
1 : "Apr"
2 : "May"
3 : "June"
4 : "July"
5 : "Aug"
6 : "Sept"
7 : "Oct"
8 : "Nov"
9 : "Dec"
10 : "Jan 2017"
11 : "Feb"
length:  12
__proto__:  Array[0]

and monthLabel is 0.

But the value of summerIndex after passing this step is -1. Is this the normal behavior in this case?



via migea

No comments:

Post a Comment