blob: d64fdd3770968ae0a8f2d5a8cf1a11f2f121c9b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// demonstrates short hand way to assign data members to an object
var foo = {
val1: function() {},
val2: null,
val3: 13,
val4: new Object()
};
// data members are public
foo.val3 = 33;
// same 33 output on both
console.log(foo.val3);
console.log(foo['val3']);
var bar = new Object();
bar.foo = function() {};
bar.foo.val1 = 99; // will get overwritten
bar.foo = {
val2: 3.14,
val3: 121
};
console.log(bar.foo['val2']);
|