javascript基础笔试题

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

<pre class="prettyprint lang-js">(() =&gt; { let x, y; try { throw new Error(); } catch (x) { (x = 1), (y = 2); console.log(x); } console.log(x); console.log(y); })(); </pre><p></p>

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

<pre class="prettyprint lang-html">&lt;div onclick=&quot;console.log('div')&quot;&gt; &lt;p onclick=&quot;console.log('p')&quot;&gt; Click here! &lt;/p&gt; &lt;/div&gt;</pre><p></p>

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

<pre class="prettyprint lang-js">for (let i = 1; i &lt; 5; i++) { if (i === 3) continue; console.log(i); }</pre><p></p>

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

<pre class="prettyprint lang-js">for (var i = 0; i &lt; 3; i++) { setTimeout(() =&gt; console.log(i), 1); } for (let i = 0; i &lt; 3; i++) { setTimeout(() =&gt; console.log(i), 1); }</pre><p></p>

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

<pre class="prettyprint lang-js">console.log(+true); console.log(!&quot;Lydia&quot;);</pre><p></p>

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

<pre class="prettyprint lang-js"> function checkAge(data) { if (data === { age: 18 }) { console.log(&quot;You are an adult!&quot;); } else if (data == { age: 18 }) { console.log(&quot;You are still an adult.&quot;); } else { console.log(`Hmm.. You don't have an age I guess`); } } checkAge({ age: 18 });</pre><p></p>

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

<pre class="prettyprint lang-js">function getAge(...args) { console.log(typeof args); } getAge(21);</pre><p></p>

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

<pre class="prettyprint lang-js">console.log([...&quot;Lydia&quot;]);</pre><p></p>

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

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

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

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

网友评论0

云产品购物券