← 返回试题目录

ECMA练习题

共 13 道。点击题干免费试做,答案在提交后查看。

难度 2

<p><strong>以下代码输出什么</strong></p> <pre> <code>const shape = { radius: 10, diameter() { return this.radius * 2 }, perimeter: () => 2 * Math.PI * this.radius, } shape.diameter() shape…

难度 3

<p><strong>以下代码输出什么</strong></p> <pre> <code>var x = 1 function foo(x, y = () => (x = 5)) { x = 9 y() console.log(x) } foo()</code></pre> <hr />

难度 2

<p>请问以下代码的输出结果是</p> <pre> !function e(){ console.log(&quot;!&quot;+e+&quot;()&quot;); }()</pre>

难度 3

<pre> <code>以下程序输出的是: function Foo(){ getName = function() { alert(1) }; return this }; Foo.getName = function () { alert(2) }; Foo.prototype.getName = function () { alert(3) }; va…

难度 2

<pre> 以下代码将会输出: function fn() { var a = 10; console.log(b) var b = 20 } fn()</pre>

难度 3

<pre> <code>var a = 10; var obj1 = { a: 20, fn: (function() { this.a *= 2; a = 5; var a = 6; return function() { this.a *= a; console.log(a) } })() } var obj2 = { a: 30 } var fn = …

难度 2

<pre> <code>if(!(&quot;a&quot; in window)){ var a = 10; } console.log(a); </code></pre>

难度 3

<pre> <code>以下调用的输出是: function Person(){ getAge = function(){ console.log(10); } return this; } Person.getAge = function(){ console.log(20); } Person.prototype.getAge = function(){…

难度 2

<pre> <code>for(var i=0; i<10; i++){ setTimeout(function() { console.log(i); },0) }</code></pre> <p>请问输出什么?<br /> 如果要输出&#39;0123456789&#39;,要怎么改?</p>

难度 2

<pre> <code><em>以下程序将会输出__() var arr=[1,2,3,4,5];</em> &nbsp;<strong>for</strong>(<strong>var</strong> i=0;i<arr.length;i++) &nbsp;{ &nbsp; &nbsp; arr[i]=<strong>function</strong>(…

难度 2

<pre> <code>以下程序将会输出 __()和__() &nbsp;<strong>var</strong> baz=3; &nbsp;<strong>var</strong> bazz={ &nbsp; &nbsp; baz: 2, &nbsp; getbaz: <strong>function</strong>( ) { &nbsp; &nbsp;…

难度 1

<pre> <code>以下代码将会输出 1 2 &nbsp;<strong>var</strong> a=4; 3 &nbsp;<strong>function</strong> <strong>b</strong>() { 4 &nbsp; &nbsp; a=3; 5 &nbsp; console.log(a); 6 &nbsp; <strong>fun…

难度 2

<p><strong>alert(1&amp;&amp;2),alert(1||0) 的输出结果将是</strong></p>

ECMA练习题 - 生命科学与前沿科技学习平台 | 必学必会