javascript type conversions [subjective]
DISCLAIMER: I may be freaking blind! (I probably am...) ;)
I am having some problems with type conversions, where a number
turns into a boolean
:
The model:
ListModel {
id: alignmentModel
ListElement { align: qsTr("Left"); value: Dock.Left } // 0
ListElement { align: qsTr("Right"); value: Dock.Right } // 2
}
Get the 2nd value
:
typeof alignmentModel.get(1).value
number
Store it in a variable:
var tmp = alignmentModel.get(1).value
Now watch:
typeof tmp
boolean
WTF?
see.notjing. did.you trace out.the value itself ?
pawel ( 2018-12-25 19:27:19 +0300 )edit@pawel I simply used
Tanghus ( 2018-12-25 22:38:26 +0300 )editconsole.log
andconsole.assert
.and the value was 2?
i did try out your sample in node and result was always: number
pawel ( 2018-12-26 09:42:52 +0300 )editThe value was
2
, but was converted totrue
And you tried it on the phone (or emulator)?
Tanghus ( 2018-12-26 15:22:49 +0300 )editnope, i was doing sonething in node.js so did try it there on my laptop
i will try it tomorrow in qtcreator
pawel ( 2018-12-26 18:44:18 +0300 )edit