当前位置: 代码迷 >> JavaScript >> 转载-十分蛋疼的JavaScript试题
  详细解决方案

转载-十分蛋疼的JavaScript试题

热度:138   发布时间:2012-10-06 17:34:01.0
转载-非常蛋疼的JavaScript试题
原文链接-http://www.nowamagic.net/javascript/js_PuzzleJavascriptQuiz.php
JavaScript有很多地方和我们熟知的C、Java等的编程习惯不同,这些不同会产生很多让人意想不到的事情。前段时间在知乎有人发了写Javascrtip试题,觉得挺好玩的,这里跟大家分享一下。
01
1
(function () {
2
    return typeof arguments;
3
})();
4

5
A. "object"
6
B. "array"
7
C. "arguments"
8
D. "undefined"
答案:A
02
1
var f = function g() {
2
        return 23;
3
    };
4
typeof g();
5

6
A. "number"
7
B. "undefined"
8
C. "function"
9
D. Eorror
答案:D
03
1
(function (x) {
2
    delete x;
3
    return x;
4
})(1);
5

6
A. 1
7
B. null
8
C. undefined
9
D. Error
答案:A
04
1
var y = 1,
2
    x = y = typeof x;
3
x;
4

5
A. 1
6
B. "number"
7
C. undefined
8
D. "undefined"
答案: D
05
01
(function f(f) {
02
    return typeof f();
03
})(function () {
04
    return 1;
05
});
06

07
A. "number"
08
B. "undefined"
09
C. "function"
10
D. Error
答案:A
06
01
var foo = {
02
    bar: function () {
03
        return this.baz;
04
    },
05
    baz: 1
06
};
07
(function () {
08
    return typeof arguments[0]();
09
})(foo.bar);
10

11
A. "undefined"
12
B. "object"
13
C. "number"
14
D. "function"
答案:A
07
01
var foo = {
02
    bar: function () {
03
        return this.baz;
04
    },
05
    baz: 1
06
};
07
typeof (f = foo.bar)();
08

09
A. "undefined"
10
B. "object"
11
C. "number"
12
D. "function"
答案:A
08
01
var f = (function f() {
02
    return "1";
03
}, function g() {
04
    return 2;
05
})();
06
typeof f;
07

08
A. "string"
09
B. "number"
10
C. "function"
11
D. "undefined"
答案: B
09
01
var x = 1;
02
if (function f() {}) {
03
    x += typeof f;
04
}
05
x;
06

07
A. 1
08
B. "1function"
09
C. "1undefined"
10
D. NaN
答案: C
10
1
var x = [typeof x, typeof y][1];
2
typeof typeof x;
3

4
A. "number"
5
B. "string"
6
C. "undefined"
7
D. "object"
答案: B
11
01
(function (foo) {
02
    return typeof foo.bar;
03
})({
04
    foo: {
05
        bar: 1
06
    }
07
});
08

09
A、“undefined”
10
B、“object”
11
C、“number”
12
D、Error
答案: A
12
01
(function f() {
02
    function f() {
03
        return 1;
04
    }
05
    return f();
06

07
    function f() {
08
        return 2;
09
    }
10
})();
11

12
A、1
13
B、2
14
C、Error (e.g. “Too much recursion”)
15
D、undefined
答案:B
13
1
function f() {
2
    return f;
3
}
4
new f() instanceof f;
5

6
A、true
7
B、false
答案:B
14
1
with (function(x, undefined){}) length;
2

3
A、1
4
B、2
5
C、undefined
6
D、Error
  相关解决方案