54
56

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Javascriptメモ:連想配列とオブジェクト

Posted at

この二つって何が違うの?

と前々から思っていたのだが、どうやら連想配列はオブジェクトの一種だと考えていいみたい。
それにしても書き方が一つでないから、正直ちょっとややこしい。

作成するとき

var pattern1 = new Object({key:"value",key:"value"});
var pattern2 = {key:"value",key:"value"};
//いずれも中身を'key':"value"としても同じ
参照するとき
var pattern1 = obj.key;
var pattern2 = obj['key'];

ちなみに

new Array({key:"value"});

はたぶん無理。
連想配列って呼び方がよくないのでは?と思う。

参考ページ:http://js.tank.jp/javascript/post.html

54
56
9

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
54
56

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?