"Avascript Advanced Programming (Third Edition)"---chapter III Basic concepts

Source: Internet
Author: User
Tags bitwise operators

This chapter focuses on some of the syntax of the Javasript language:

1. Strict mode: Open: "Use strict";

2. Variables: all defined by VAR, used in functions called local variables, can not be used globally.

3. Data type: Undefined,null,boolean,number,string,object. You cannot define a custom type.

1) Use the TypeOf operator to return the data type of the variable.

2) about floating-point numbers, because of the accuracy problem, do not attempt to compare a floating-point number.

Problem with numeric range: in ECMAScript, the minimum value is number.min_value and the maximum value is number.max_value. Out of range display infinity. You can use the isfinite () function to determine whether the range is between ranges.

Numeric conversion: Used to convert a non-numeric value to a value: Number() Parenint () parsefloat ( ) The first function is used to transform any data type. The latter two apply to strings.

The number () function has the following conversions: If it is a Boolean, go to 1 or 0. Value, go directly out. Null value, go out of 0.undefined, and go out of Nan. String words, if only the number is turned out, if there are characters, turn out Nan. If it is empty, turn out 0.

The Parsenint () function has the following transformations: see if the first character is a number to decide whether to go out. For the problem of the binary, provide the second parameter is the binary number.

The Parsenfloat () function has the following transformations: It only applies to decimal when it is converted, so the hexadecimal data is turned out 0.

3) The length of any one string can be output through object.length.

Note: String variables cannot be assigned after they are created, unless they are added later by the + operator connection.

The value of a data type (except null and undefined), a Boolean, an object, and a string can be converted to a string by the toString () method . This method can change the binary by passing in the number cardinality. A common function is the string () function, which, if null and undefined, is returned as is, and other types are returned by the ToString () method.

4) Object type: Create custom object: var o = new Object ();

Object objects have some common properties. View the document in detail.

4. Bitwise operators:

1) Bitwise non: var num = 25; var num2 = ~num1;

Bitwise non-intrinsic: negative value when operating-1.

2) Bitwise VS: var result = & 1;

3) Bitwise OR: var result = 25 | 1;

4) Bitwise XOR: var reslut = 25 ^ 1;

5) Shift Left: var oldValue = 5;

var newvalue = OldValue << 5;

6) Right Shift: >>

5) Unsigned Right shift: >>>

5. Boolean operators

1) Logical non-:!

  

"Avascript Advanced Programming (Third Edition)"---chapter III Basic concepts

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.