After returning to work this morning, I encountered some strange behavior that disappeared after restarting the server. Despite my efforts, I couldn't recreate it. So, consider this question "solved" and feel free to delete it if necessary. I'm not sure if I have permission to do so.
My attempt was to compare the height of the window and document during a resize event, using an if/else statement based on their values. However, despite logging the data, the basic logic doesn't seem to be working as expected:
Within the if
statement, I logged
"TRUE [number one] >= [number two]"
, while in the else
statement, I logged "FALSE [number one] >= [number two]"
. This occurred during a window resize event where only the width changed, keeping the heights constant. With identical numbers, I assumed it would always log the TRUE condition, but instead received this output:
[...]
TRUE 548 >= 548
FALSE 548 >= 548
TRUE 548 >= 548
FALSE 548 >= 548
TRUE 548 >= 548
FALSE 548 >= 548
TRUE 548 >= 548
FALSE 548 >= 548
[...]
The value type is consistently "number", always an integer with no floats involved. I also tested this in IE9 and FF35.
Would someone kindly explain what is happening here? How can I prevent this unexpected behavior from occurring?
Thank you!
EDIT: The original question has been edited for clarity. While improving my English (as I am still learning), the new version changes the original meaning significantly. The focus should be on understanding the behavior of the if statement with equal values, rather than obtaining element heights. I was simply detailing how I arrived at my query. – Correcting spelling mistakes is one thing, but altering the text's interpretation leads to a different discussion altogether.