JS face question (i.)

Source: Internet
Author: User

1. JS Six basic data types: string Boolean Number object undefined function

typeof returns a string of six kinds: string Boolean Number object undefined function

var a=1; if (function  f () {}) {    x+ =typeof  F;} // value of x: "1undefined"
At this point function f () {} is not a functional declaration, it is converted to true, and internal f is undefined

2, instanceof

Instance a instanceof B (A is an instance of B), returns True, False

[] instanceof Array;//true

3 . Delete to remove the member variable of the object

(function(x) {delete  x;   Falsealert (x);}) (1)// results: 1
Because delete failed to delete X

4. js comma operator

var a= (All-in-one);//Final A has a value of 3, select the last value

5, JS pre-analysis 

(function  f () {    function aaa () {return 1};     return aaa ();     function aaa () {return 2};}) (); // The returned result is 2 because the code is pre-parsed before execution, and the following function declaration overrides the previous

6. Function parameters equivalent to local variables

var a=10; function aaa (a) {//A is equivalent to a copy of the global variable, which is a different parameter from the global variable A, a local variable     a+=3;} aaa (a); alert (a);// At this point, we find the global a, basic type of copy operation, Global A has never been changed//10


var a=10;
function aaa () {
a+=3;//assignment operation, JS has no block-level scope, so changes the value of global variable A
}
AAA ();
alert (a);
13

JS face question (i.)

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.