- var a = [ 0, 1, 2 ];
- alert( a.length );
-
- a[ 3 ] = 3;
- alert( a.length );
var a = [ 0, 1, 2 ];
alert( a.length ); // 3
a[ 3 ] = 3;
alert( a.length ); // 4
- var a = 3;
- var b = a;
- alert( "a = " + a );
- alert( "b = " + b );
-
- a = 5;
- alert( "a = " + a );
- alert( "b = " + b );
var a = 3;
var b = a;
alert( "a = " + a ); // a = 3
alert( "b = " + b ); // b = 3
a = 5;
alert( "a = " + a ); // a = 5
alert( "b = " + b ); // b = 3
- var a = new Object();
- a.property = 10;
-
- var b = new Object();
- b = a;
-
- alert( "a.property = " + a.property );
- alert( "b.property = " + b.property );
-
- a.property = 5;
- alert( "a.property = " + a.property );
- alert( "b.property = " + b.property );
-
- b.property = 8;
- alert( "a.property = " + a.property );
- alert( "b.property = " + b.property );
var a = new Object();
a.property = 10;
var b = new Object();
b = a;
alert( "a.property = " + a.property ); // a.property = 10
alert( "b.property = " + b.property ); // b.property = 10
a.property = 5;
alert( "a.property = " + a.property ); // a.property = 5
alert( "b.property = " + b.property ); // b.property = 5 !!!
b.property = 8;
alert( "a.property = " + a.property ); // a.property = 8 !!!
alert( "b.property = " + b.property ); // b.property = 8
- var a = { property : 10 };
- var b = a;
- alert( "a.property = " + a.property );
- alert( "b.property = " + b.property );
-
- a.property = 5;
- alert( "a.property = " + a.property );
- alert( "b.property = " + b.property );
-
- b.property = 8;
- alert( "a.property = " + a.property );
- alert( "b.property = " + b.property );
var a = { property : 10 };
var b = a;
alert( "a.property = " + a.property ); // a.property = 10
alert( "b.property = " + b.property ); // b.property = 10
a.property = 5;
alert( "a.property = " + a.property ); // a.property = 5
alert( "b.property = " + b.property ); // b.property = 5 !!!
b.property = 8;
alert( "a.property = " + a.property ); // a.property = 8 !!!
alert( "b.property = " + b.property ); // b.property = 8
- オブジェクト : 変数に代入したとき、その実体ではなく参照が代入される
- プリミティブ : 実体がそのまま代入される
0 件のコメント:
コメントを投稿