僕の備忘録(PC、UN*X、ネットワーク関連が中心)なんです。
自分の書いたところは適当(な時とか)に書き換えますので御了承を。
まずは配列から。<html> とprint()省略。
var ar = []; ar[0] = "foo"; ar[1] = "bar"; ar[2] = "baz"; print("type of like_ar is", typeof(like_ar)); print("ar[1] is ", ar[1]); print("the length of ar is", ar.length); print("pop method of ar is", ar.pop());
type of ar is object ar[1] is bar the length of ar is 3 pop method of ar is baz
なんか無理に。
var like_ar = new Object() ; like_ar.length = 3; like_ar[0]="foo"; like_ar[1]="bar"; like_ar[2]="baz"; print("type of like_ar is", typeof(like_ar)); print("like_ar[1] is", like_ar[1]); print("the length of like_ar is", like_ar.length);
ここまでは一緒。
type of like_ar is object like_ar[1] is bar the length of like_ar is 3
しかし、こちらは配列ではないので、配列のメソッドもない。
print("pop method of like_ar is", like_ar.pop());
エラー: like_ar.pop is not a function ソースファイル: $URL/like_array.html 行: 22
「配列の要素」のようなものを増やしても、lengthの 値も変らない。
like_ar[3]="qux"; print("like_ar[3] is", like_ar[3]); print("the length of like_ar is", like_ar.length);
like_ar[3] is qux the length of like_ar is 3
多分そのはず。
リンクはご自由にどうぞ。でもURLや内容が変った場合はあしからず。