Comparison operator of Flash operations

Source: Internet
Author: User
Comparison operation = and! = To check whether two expressions are equal, as first converts them to the same data type, and then judges whether the two values are equal, "6" and "6" are equal, because the string "6" is converted to the 6 trace (5 = 6) of the number; // displays: falsetrace (6 = 6); // displays: truetrace (6 = "6"); // displays: truetrace (5 = "6"); // displays: false if strict data check is disabled, strict comparison is still required. You can use strict equality and inequality operators, ===and! =. Before comparing these operators, check whether the values have the same data. The reason for the Data Type difference, so = returns the straight value ,! === Returned false trace (6 === 6); // displays: truetrace (6 === "6"); // displays: falsetrace (6! = 6); // displays: false

Trace (6! = "6"); // displays: True

Use is to check the data type of the Variable

VaR quantity: Int = 5;

If (quantity is int ){

Trace ("Yippee. It's an integer .");

}

When an expression cannot be calculated, the variable is an invalid number. Nan is short for not a number. Nan is also a number.

VaR quantity: Number = 15-"rabbits ";

Trace (typeof quantity); // displays: "Number"

How to test whether the variable is Nan and use the isnan () function

VaR quantity: Number = 15-"rabbits ";

If (isnan (Quantity )){

Trace ("Sorry, that is not a valid number .");

}

When comparing composite objects, compare whether the reference addresses of objects are the same

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.