blob: c4b491feb2ed480c77c6b22e6461b9ebd94dd8b0 (
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;
bar.foo = {
val2: 3.14,
val3: 121
};
console.log(bar.foo['val2']);
|