Data type, operator

Source: Internet
Author: User
  • Six types of data: object, string, null, Undefined, boolean, number;
    • Any data type + "" will be converted into a string;
    • null and undefined Although both are empty, null typeof is Object,undefined typeof is undefined;
    • Number conversion has pareseint and Paresefloat two, the former is converted to integers, the latter is the conversion is a decimal, but they in the parsing of numbers and strings, encountered a string will terminate parsing;
    • var num = 1.2345;num2 = num.tofixed (2);//will save two digits after the decimal point
    • Boolean True and False when the operation is true, the return of 1,false is 0;
  • Operators include: arithmetic character +-*/,++--; logical character && | | <><=>= = = = = = = = = equals! = Not equal to
    • The difference between a++ and ++a: The former first continues the operation, then itself + +, the latter is the first self + +, and then continue the operation;
    • The difference between a--and--a: ibid;
    • Cases:

      var m=10;
      var a=2;
      var m1=m+a++;
      var m2=m+++a;
      Console.log (M1);//11
      Console.log (m2);//13

Data type, operator

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.