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
A: barbarbarbar
B: barbarbarundefined
C: barbarundefinedbar
D: undefinedbarundefinedbar
举一反三
- 查看一下代码 ,请问输出正确的是|var Test ={| foo:"test",| func:function () {| var self=this;| console.log(this.foo);| console.log(self.foo);| (function () {| console.log(this.foo);| console.log(self.foo);| })();| }|};|Test.func(); A: test test undefined test B: test undefined undefined test C: test test undefined D: test test test test
- var foo = '123';function print() { this.foo = '789'; console.log(foo);}print();
- 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
- 在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