js基础练习题(6)

10.其他

1.选择题

var name = 'World!';
(function () {
    if (typeof name === 'undefined') {
        var name = 'Nodeing';
        console.log('Goodbye ' + name);
    } else {
        console.log('Hello ' + name);
    }
})();
// 输出结果
A: Goodbye Nodeing

B: Hello Nodeing

C: Hello undefined

D: Hello World

2.选择题

["1", "2", "3"].map(parseInt)
//输出结果
A:["1", "2", "3"]

B:[1, 2, 3]

C:[0, 1, 2]

D:other

3.选择题

var val = 'nodeing';
console.log('Value is ' + (val === 'noding') ? 'Something' : 'Nothing');
// 输出结果
A: Value is Something

B: Value is Nothing

C: NaN

D: other

4.选择题

function showCase(value) {
    switch(value) {
    case 'A':
        console.log('Case A');
        break;
    case 'B':
        console.log('Case B');
        break;
    case undefined:
        console.log('undefined');
        break;
    default:
        console.log('Do not know!');
    }
}
showCase(new String('A'));
// 选项
A: Case A

B: Case B

C: Do not know!

D: undefined

5.选择题

function showCase2(value) {
    switch(value) {
    case 'A':
        console.log('Case A');
        break;
    case 'B':
        console.log('Case B');
        break;
    case undefined:
        console.log('undefined');
        break;
    default:
        console.log('Do not know!');
    }
}
showCase(String('A'));
A: Case A

B: Case B

C: Do not know!

D: undefined

6.选择题

var a = [0];
if ([0]) { 
  console.log(a == true);
} else { 
  console.log("wut");
}
// 选项
A: true

B: false

C: "wut"

D: other

7.选择题

(function(){
  var x = y = 1;
})();
console.log(y);
console.log(x);
// 选项
A: 1, 1

B: error, error

C: 1, error

D: other

8.选择题

var a = /123/,
    b = /123/;
a == b
a === b
A: true, true

B: true, false

C: false, false

D: other

9.选择题

var END = Math.pow(2, 53);
var START = END - 100;
var count = 0;
for (var i = START; i <= END; i++) {
    count++;
}
console.log(count);
A: 0

B: 100

C: 101

D: other

螺钉课堂视频课程地址:http://edu.nodeing.com

猜你喜欢

转载自www.cnblogs.com/dadifeihong/p/12028655.html