LoginSignup
0
0

More than 5 years have passed since last update.

【JavaScript】「変数」について学ぶ

Last updated at Posted at 2018-08-25

「ノンプログラマのためのJavaScript はじめの一歩」 第2章 JavaScriptの文法 より

  • 変数とは、データを保存しておく箱
  • どんなデータでも入れることができる

試してみたこと

変数にはどんなデータでも入れることができます。
P.24より

入れる値によってどんなデータ型が返ってくるか、typeof を使って確認してみる。

var a;
typeof a //-> "undefined"
a = 1;
typeof a //-> "number"
a = '1';
typeof a //-> "string"
a = [ 1, 2, 3 ];
typeof a //-> "object"
a = { b: 1 }
typeof a //-> "object"

配列もオブジェクトも object らしい。
データの種類については、本を読み進めていく方が理解できそうだったので、今はこれを疑問に持ちながら先に進んでいこうと思う。


参考サイト
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