Run, my JavaScript (1)

Source: Internet
Author: User

the front of the play come ~ ~ ~ Small partners take a small bench, with good melon seeds, see the fun1. Strict mode

Defines a different parsing and execution model for JavaScript

In this mode, some of the indeterminate behavior in JavaScript will be handled, and some unsafe operations will throw an error.

' use strict ' is just a compilation instruction that can be declared at the beginning of a program or placed inside a function.

2. Using the var operator

var is a keyword that can hold any value and the uninitialized value will also hold a special value---undefined.

Although omitting Var can set a variable to a global variable, assigning a value to an undeclared variable throws a reference error error in strict mode.

3. Data type

Undefined (value undefined), unique value, the uninitialized variable is automatically assigned the Undefined value, but the initialization should be displayed more

Null (null object pointer instead of NULL value), unique value, the variable that holds the object has not yet saved the object, it should be initially null

Boolean (Boolean), two-value true/false, case-sensitive, transform function Boolean (), return the corresponding Boolean value

Number, two type integer/decimal, octal first is 0, number sequence is 0~7, hexadecimal first is 0x, numeric sequence is 0~9 and a~f (ignoring case), with a special value Nan

String (string), can be single or double quotation marks, the value of the character once set is difficult to transform, transformation function tostring ()/string ()

Object (object), a set of data and functions, var o = new Object (), with the following properties and methods:

(1) Constractor constructor

(2) hasOwnProperty (property name), the attribute name must exist as a string

(3) isPrototypeOf (object), objects prototype

(4) toString (), the string that returns the object

(5) ValueOf (), returns the value of the object

4. Function parseint () and parsefloat () difference

parseint () Parsefloat ()
Resolving integers Resolving decimals
has two parameters (string to parse, cardinality) Only the decimal is parsed, only one argument (the string to parse), and the leading 0 is always ignored
Cannot parse decimal point Only one decimal is parsed, and the second terminates parsing
JavaScript can only operate on 32-bit values, so it is converted to 32 bits and then manipulated when the 64 bits are manipulated. But there are side effects, and nan and infinity are treated as 0.

5. Logic and/or logic

Logic and Logical OR
Symbol representation && ||
Rules Object && Any value, returns the second operand Object | | An arbitrary value that returns the first operand
Any value && object that returns a second operand only if the first operand is true Any value | | An object that returns the second operand if the first operand is false
Object && object, returns the second object Object | | Object that returns the first object
null&& any value, returns null null| | NULL, return NULL
nan&& any value, return Nan nan| | Nan, returning Nan
Operation method Short-circuit operation Short-circuit operation
False if the first operand is false True if the first operand is true

6. Addition and subtractionwhen doing different operations, in addition mode, the operands of different types will eventually be converted to string types for stitching and the subtraction mode is to convert the string type to the numeric type in the calculation7. Equality and not wanting to be equal/congruent and not congruent==/! = ===/! ==existence of coercion type conversions guarantees the integrity of data types8. Comma operatorused to perform multiple operations in a single statement, many to declare multiple variablesused to assign, return the last item in an expression
var num = (5,1,4,8,0);    Returns 0
9.for...in Statementsenumerates the properties of an object, noting that the order of the objects is unordered.
for (var propname in window) {document.write (propname);}
10.label StatementsAdd tags to your code

Run, my JavaScript (1)

Related Article

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.