DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 讓人蛋疼的JavaScript語法特性
讓人蛋疼的JavaScript語法特性
編輯:關於JavaScript     

在知乎上看到的有人發布的和javascript有關的試題,和大家分享下,雖然是N久前的事了,但這些題相當經典,不免讓人覺得javascript真是門蛋疼的語言。

1.
代碼如下:
  (function () {
        return typeof arguments;
    })();

    A. "object"
    B. "array"
    C. "arguments"
    D. "undefined"

答案:A

2.
代碼如下:
var f = function g() {
                return 23;
            };
        typeof g();

        A. "number"
        B. "undefined"
        C. "function"
        D. Eorror

答案:D

3.
代碼如下:
(function (x) {
            delete x;
            return x;
        })(1);

        A. 1
        B. null
        C. undefined
        D. Error

答案:A

4.
代碼如下:
        var y = 1,
        x = y = typeof x;
        x;

        A. 1
        B. "number"
        C. undefined
        D. "undefined"

答案:D

5.
代碼如下:
    (function f(f) {
            return typeof f();
        })(function () {
            return 1;
        });

        A. "number"
        B. "undefined"
        C. "function"
        D. Error

答案:A

6.

代碼如下:
var foo = {
            bar: function () {
                return this.baz;
            },
            baz: 1
        };
        (function () {
            return typeof arguments[0]();
        })(foo.bar);

        A. "undefined"
        B. "object"
        C. "number"
        D. "function"

答案:A

7.

代碼如下:
var foo = {
            bar: function () {
                return this.baz;
            },
            baz: 1
        };
        typeof (f = foo.bar)();

        A. "undefined"
        B. "object"
        C. "number"
        D. "function"

答案:A

8.
代碼如下:
var f = (function f() {
            return "1";
        }, function g() {
            return 2;
        })();
        typeof f;

        A. "string"
        B. "number"
        C. "function"
        D. "undefined"

答案:B

9.
代碼如下:
 var x = 1;
 if (function f() {}) {
 x += typeof f;
 }
 x;

 A. 1
 B. "1function"
 C. "1undefined"
 D. NaN

答案:C

10.
代碼如下:
var x = [typeof x, typeof y][1];
        typeof typeof x;

        A. "number"
        B. "string"
        C. "undefined"
        D. "object"

答案:B

11.

代碼如下:
(function (foo) {
            return typeof foo.bar;
        })({
            foo: {
                bar: 1
            }
        });

        A、“undefined”
        B、“object”
        C、“number”
        D、Error

答案:A

12.
代碼如下:
(function f() {
            function f() {
                return 1;
            }
            return f();
            function f() {
                return 2;
            }
        })();

        A、1
        B、2
        C、Error (e.g. “Too much recursion”)
        D、undefined

答案:B

13.
代碼如下:
 function f() {
        return f;
    }
    new f() instanceof f;

    A、true
    B、false

答案:B

14.
代碼如下:
with (function(x, undefined){}) length;

        A、1
        B、2
        C、undefined
        D、Error

答案:B

15.
代碼如下:
以下哪條語句會產生運行錯誤:()         
A.var obj = ();          
B.var obj = [];       
C.var obj = {};       
D.var obj = //;

答案:A

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved