Page 1 of 1

[meaningless]Object in comparison (not to compare object)

Posted: 05 Nov 2015, 05:48
by RobertL
Document wrote:If either of the inputs is not a number, both are compared alphabetically
Currently, {}<0 (or o<0 which o is an object) is true and then, {}>0, o>0 are false. It seems object is convert to empty string, then ""<0 are compared alphabetically.
I think can't compare between object (or anything can't convert to number nor numerical string) and number.
I hope these comparison discriminant returns empty string.
3# wrote:Since condition of empty is treated as false, there still will be some conflict, even compare returns empty - need to use (a<0)=false to confirm false.
Maybe I over misused weak type, which simplify variable define and assign, I'd better check type first, if necessary.

Re: Object in comparison

Posted: 05 Nov 2015, 06:27
by nnnik
Just write a simple function and use it instead of the = operator.

Re: Object in comparison

Posted: 05 Nov 2015, 08:13
by RobertL
Since condition of empty is treated as false, there still will be some conflict, even compare returns empty - need to use (a<0)=false to confirm false.
Maybe I over misused weak type, which simplify variable define and assign, I'd better check type first, if necessary.
Thank you @nnnik