在Java script中,运行下面代码的结果是 function foo(x){ var num=5; bar=function(y){ return (x+y+(++num)); } } console.log(foo(2)); console.log(bar(10)); console.log(bar(10));"
undefined,18,19
举一反三
- 在Javascript中,运行下面代码的结果是( )<br/>function foo(x){<br/>var num=5;<br/>bar=function(y){<br/>return (x+y+(++num));<br/>} <br/>}<br/>console.log(foo(2));<br/>console.log(bar(10));<br/>console.log(bar(10));" A: undefined,18,19 B: 17,18,19 C: 5,18,19 D: undefined,18,18
- 以下代码执行后, num 的值是多少?var foo = function(x, y) {return x - y;};function foo(x, y) {return x + y;}var num = foo(1, 2);console.log(num);
- var bar=123 function foo () { console.log(bar) var bar=456 console.log(bar); } console.log(bar) foo() 请问输出的结果依次为 A: 123,456,123 B: undefined,456,123 C: 123,undefined,456 D: 123,123,456
- 有下列代码执行后的结果是var x = 10; function f1( num ){ ++ num; } var y = f1( x );console.log( 'x=' + x + '; y=' + y ); A: x=10; y=undefined B: x=10; y=11 C: x=11; y=11 D: x=11; y=undefined
- varmyObject={foo:"bar",func:function(){varself=this;console.log(this.foo);console.log(self.foo);(function(){console.log(this.foo);console.log(self.foo);}());}};myObject.func();程序的输出是什么? A: barbarbarbar B: barbarbarundefined C: barbarundefinedbar D: undefinedbarundefinedbar
内容
- 0
有代码: function foo(){ var a=10; return function(){ console.log(a++) } } foo()(); 运行之后,会在控制台中打印()。 A: 10 B: 11 C: 函数体 D: 报错
- 1
中国大学MOOC:"以下代码片段运行后,在console面板显示的结果是( ) wx.onAccelerometerChange(function (res) { console.log(res.x) console.log(res.y) console.log(res.z)})";
- 2
Which of the following are NOT valid if/else statements in Python, assuming x and y are defined appropriately: A: if x < y: print('foo') else: print('bar') B: if x < y and x > 10: print('foo') C: if x < y: print('foo'); print('bar'); print('baz') D: if x < y: print('foo') elif y < x: print('bar') else: print('baz')
- 3
function a(x) { return x * 2; } var a=1; console.log(a); 执行以上代码的结果是
- 4
以下代码片段运行后,在console面板显示的结果是() wx.onCompassChange(function(res){ console.log(res.direction) })