在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));"
举一反三
- 在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