JavaScript

[クイズ]javascriptと仲良くなるための一歩 第45話「this参照4」

問題

var x = 1;
var obj3 = {
           x:3,
           doit3: function(){ console.log("method is called." + x); }
          }
obj3.doit3(); //=> ?

:mouse:
:cow:
:tiger:
:rabbit:
:dragon_face:
:snake:
:horse:
:sheep:
:monkey_face:
:bird:
:dog:
:boar:
:mouse:
:cow:
:tiger:
:rabbit:
:dragon_face:
:snake:
:horse:
:sheep:
:monkey_face:
:bird:
:dog:
:boar:

答え

var x = 1;
var obj3 = {
           x:3,
           doit3: function(){ console.log("method is called." + x); }
          }
obj3.doit3(); //=> method is called.1