[SOLVED]Strange JS behavior
-
Hi there!
I've just stumbled on some strange JavaScript behavior which I don't understand totally.
I have the following code for one of the QML item property:
@xMax: {
var maximum = 0;for(var i = 0; i < xMarks.length; i++){ var data = xMarks[i]; console.log("data: " + data + ", maximum:" + maximum + ", result: " + (data > maximum)) if(data > maximum){ maximum = data; } } return maximum; }@
And it prints: !http://ybex.com/t/in8iai32h6khg3r2u72ph5x5kbb4homykr9ue41s.png(that)!
It works as such with all values more then 6. It works as it should with all values less then 6. Is it a bug? It seems very strange to me -
Hi ixSci,
I have tried your example and it works for me.
What is the type of the xMarks array? I created an own one for the test:
@
var xMarks = new Array(6.0, 12.0, 18.0, 30.0);
@
With this array the console.log prints it in integer format instead of double (e.g. "6" instead of "6.00").
Could you share more information about the using of xMax property? I just started to get acquainted with QML.