On the collation of 14 Devil JS questions

Source: Internet
Author: User

1. (function () {

Return typeof arguments

})();

when returned here is the argument type, it is an array of classes, also on the object, so is object, exactly who is [object Argumens]

2

var f = function g () {

return 23;

};

typeof G ();

The problem is named function expression, but function name G only in the name scope valid, so the result is wrong, notice that the subject in the old IE is resolved to function declaration, that is, the result is number;

3

(function (x) {

Delete x;

return x;

}) (1);

Delete Deletes object properties, so this returns to 1;

4

var y = 1, x = y = typeof x;

X

It's obvious that undefined

5

(function f (f) {

Return typeof F ();

}) (function () {return 1;});

Number

6

var foo = {

Bar: function () {

return This.baz;

},

Baz:1

};

(function () {

Return typeof Arguments[0] ();

}) (Foo.bar);

Answer: undefined;

7

var foo = {

Bar:function () {

return This.baz;},

Baz:1}

typeof (F = foo.bar) ();

The subject is dead, the answer undefined, notice that the object only holds a reference to the method and does not hold the method

8

var f = (

function f () {

return "1";

},

function g () {

return 2;

}

)();

typeof F;

The answer is number;

9

var x = 1;if (function f () {}) {  x + = typeof F;} X
1undefined
10
var x = [typeof x, typeof y][1];typeof typeof X;
X is undefined
The type of x is a string;

11
(function (foo) {  return typeof Foo.bar;}) ({foo: {bar:1}});
It is obvious that undefined;
12
(function f () {  function f () {return 1;}  return f ();  function f () {return 2;}}) ();
The answer is 2, the variable promotion principle
13
function f () {return F;} New F () instanceof F;
False
14
With (function (x, undefined) {}) length;
Return when he arguments the length of the











On the collation of 14 Devil JS questions

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.