LoginSignup
0
0

More than 5 years have passed since last update.

[クイズ]javascriptと仲良くなるための一歩 第30話「関数」

Posted at

問題

第1問

function doit(){
  fn();
  function fn() { console.log("called"); }
}

doit(); //=> ?

第2問

function doit(){
  fn();
  var fn = function () { console.log("called"); }
}

doit(); //=> ?

: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:

問題

第1問

function doit(){
  fn();
  function fn() { console.log("called"); }
}

doit(); //=> called

第2問

function doit(){
  fn();
  var fn = function () { console.log("called"); }
}

doit(); //=> Uncaught TypeError: fn is not a function

"関数宣言文の巻き上げ"からの問題でした:hugging:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0