在Javascript中,运行下面代码的结果是( )
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));"
A: undefined,18,19
B: 17,18,19
C: 5,18,19
D: undefined,18,18
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));"
A: undefined,18,19
B: 17,18,19
C: 5,18,19
D: undefined,18,18
举一反三
- 在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));"
- 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
- 以下代码执行后, num 的值是多少?var foo = function(x, y) {return x - y;};function foo(x, y) {return x + y;}var num = foo(1, 2);console.log(num);
- 以下代码的运行结果是[br][/br]def fun(num):[br][/br] num=num*2[br][/br]x=5[br][/br]print(x) A: 10 B: 5 C: 报错 D: 2
- 在html中嵌入以下代码,在控制台输出的是(): [script] console.log(a); [/] [script] var b = 8; console.log(a); [/] function test1(){ return console.log(1) } [br][/br] function test2(){ [br][/br] return 0 [br][/br] } [br][/br] console.log(test1()); [br][/br] console.log(test2()); A: 报错,报错 B: 报错,8 C: 报错,不输出任何东西 D: a,8