以下代码执行后, num 的值是多少?var foo = function(x, y) {return x - y;};function foo(x, y) {return x + y;}var num = foo(1, 2);console.log(num);
举一反三
- 在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
- 有下列代码执行后的结果是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
- 阅读下面的JavaScript代码 function f(y) { var x = y * y; return x; } for(var x = 0; x < 5; x ++) { y = f(x); document.writeln(y); } 输出结果是
- function a(x) { return x * 2; } var a=1; console.log(a); 执行以上代码的结果是