LoginSignup
0
0

More than 5 years have passed since last update.

[クイズ]javascriptと仲良くなるための一歩 第37話「配列の要素アクセス」

Posted at

問題

var arr = [0,1,2,3,4,5,6,7,8,9,10,11]
var str = "1"
arr[str]   //=> ?
arr[str+1] //=> ?

: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 arr = [0,1,2,3,4,5,6,7,8,9,10,11]
var str = "1"
arr[str]   //=> 1
arr[str+1] //=> 11
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