Home > Web Front-end > JS Tutorial > Painful JavaScript syntax features_Basic knowledge

Painful JavaScript syntax features_Basic knowledge

WBOY
Release: 2016-05-16 16:34:41
Original
1342 people have browsed it

I saw some test questions related to JavaScript posted by someone on Zhihu, and I would like to share them with you. Although it was a long time ago, these questions are quite classic, which makes people think that JavaScript is really a painful language. .

1.

Copy code The code is as follows:

(function () {
          return typeof arguments;
})();

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

Answer: A

2.

Copy code The code is as follows:

var f = function g() {
Return 23;
            };
        typeof g();

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

Answer: D

3.

Copy code The code is as follows:

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

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

Answer: A

4.

Copy code The code is as follows:

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

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

Answer: D

5.

Copy code The code is as follows:

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

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

Answer: A

6.

Copy code The code is as follows:

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

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

Answer: A

7.

Copy code The code is as follows:

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

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

Answer: A

8.

Copy code The code is as follows:

var f = (function f() {
              return "1";
}, function g() {
               return 2;
         })();
        typeof f;

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

Answer: B

9.

Copy code The code is as follows:

var x = 1;
if (function f() {}) {
x = typeof f;
}
x;

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

Answer: C

10.

Copy code The code is as follows:

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

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

Answer: B

11.

Copy code The code is as follows:

(function (foo) {
               return typeof foo.bar;
         })({
foo: {
bar: 1
            }
        });

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

Answer: A

12.

Copy code The code is as follows:

(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

Answer: B

13.

Copy code The code is as follows:

function f() {
         return f;
}
new f() instanceof f;

A. true
B、false

Answer: B

14.

Copy code The code is as follows:

with (function(x, undefined){}) length;

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

Answer: B

15.

Copy code The code is as follows:

Which of the following statements will generate a runtime error: ()            
A.var obj = ();    
B.var obj = []; 
C.var obj = {}; 
D.var obj = //;

Answer: A

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template