javascript基础笔试题

1、请选择下面js代码的执行结果收藏

(() => {
            let x, y;
            try {
                throw new Error();
            } catch (x) {
                (x = 1), (y = 2);
                console.log(x);
            }
            console.log(x);
            console.log(y);
 })();

2、请选择下面代码点击后的执行结果收藏

<div onclick="console.log('div')">
      <p onclick="console.log('p')">
        Click here!
      </p>
</div>

3、请选择下面js代码的执行结果收藏

for (let i = 1; i < 5; i++) {
  if (i === 3) continue;
  console.log(i);
}

4、请选择下面js代码的执行结果收藏

for (var i = 0; i < 3; i++) {
     setTimeout(() => console.log(i), 1);
}
for (let i = 0; i < 3; i++) {
    setTimeout(() => console.log(i), 1);
}

5、请选择下面js代码的执行结果收藏

console.log(+true);
console.log(!"Lydia");

6、请选择下面js代码的执行结果收藏

    function checkAge(data) {
        if (data === {
            age: 18
        }) {
            console.log("You are an adult!");
        } else if (data == {
                age: 18
            }) {
            console.log("You are still an adult.");
        } else {
            console.log(`Hmm.. You don't have an age I guess`);
        }
    }

    checkAge({
        age: 18
    });

7、请选择下面js代码的执行结果收藏

function getAge(...args) {
        console.log(typeof args);
}

getAge(21);

8、请选择下面js代码的执行结果收藏

console.log([..."Lydia"]);

9、下面这些值哪些是假值?收藏

10、下面这些值哪些是假值?收藏

11、eval(5+3*4)+eval(3+4*5) 的值是多少收藏

12、isNaN("abc")返回值是多少收藏

网友评论0