judge value then cause result different in javascript

Do not judge the count’s value, the code works fine, I can read the response from serial port.
enter image description here
If I judge the count’s value first, the count’s value will always be zero, I make true my serial port device works fine.
enter image description here

Can anyone help me? Please!

I make true my serial port device is always ok, the only problem is I can’t judge the readableLength first, if I did, it’s value would always be zero