JavaScript learning notes _ about expressions and statements, javascript learning notes

Source: Internet
Author: User

JavaScript learning notes _ about expressions and statements, javascript learning notes

Expressions and statements

Eval () has only one parameter

If the parameter is not a string, this parameter is directly returned;

When the parameter is a string, it uses the string as JavaScript code for compilation. If the compilation fails, a syntax error is thrown. If the compilation succeeds, the code is executed and the value of the last statement is returned, if no value exists, undefined is returned.

Eval () uses the scope environment of the variables that call it

The string parameter it receives must have semantics when it is used as a separate code; otherwise, compilation fails.

Delete OPERATOR: Used to delete the free attributes and elements of an array of objects,

After an attribute is deleted, the attribute does not exist. After an array element is deleted, a hole with the undefined value is left in the array, and the array length remains unchanged;

If you try to delete an attribute that cannot be deleted, false is returned. If the deletion is successful or the deletion operation does not take effect, true is returned.

Delete cannot be deleted:

1. built-in core and client attributes cannot be deleted;

2. variables declared through the var statement cannot be deleted;

3. function and function parameters defined by function statements cannot be deleted.

4. unconfigurable properties cannot be deleted

Void OPERATOR: The void operand is executed normally, but the value of the operand is ignored and undefined is returned.

Void has the following functions:

* Using void 0 to get undefined is more reliable and reliable than using literally undefined;

* Fill in the href of <a> to ensure that no page Jump is generated when you click it. Fill in the src of <image> to ensure that no spam request is sent to the server. Href = 'javascript: void (0 );'

No matter whether a break statement has a label or not, its control cannot cross the boundary of the function! That is, you cannot jump from the inside of the function to the outside of the function.

Object. create (p, [x])

This method creates a new object based on object p and returns the object. Optional x is used to further describe the object attributes;

Var p1 = Object. create (p); // create Object p1, which inherits from Object p (based on p)

That is, the prototype attribute value of p1 is p.

Differences between P. x and P ['X:

When accessing P. x, only the property named x can be fixed;

P ['X'] is flexible. You can dynamically modify the value of the character string in [] to access different attributes, such as P ['X' + I].

The combination of logic and "&", logic or "|": Short Circuit

The & ensures that, before reading the length attribute, both book and book. subtitle are true values, that is, objects

Var len = book & book. subtitle & book. subtitle. length;

Ensure that the value of x is from a ~ In f, the first value is the true value, ignoring the true value

Var x = a | B | c | d | e | f;
 
If (! Buy) {...} When buy is a false value, run {...}

Pass! ! X to obtain an equivalent Boolean value.

The above is the JavaScript learning notes for everyone. _ all the content about expressions and statements. I hope it will be helpful to everyone ~

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.