2015-10-28 57 views

回答

0

它調用一個對象初始化程序,有時也稱爲對象字面量。

這僅僅是

var a = { bar: "foo"}; // creates an object with the property bar 

空形式是一樣的

var a = {}; // creates an object with no user defined properties 
a.bar = "foo"; // add the property bar to a 

這同樣適用於陣列。

var a = []; // creates an array with no items 
a[0] = 1; 
a[1] = 2; 

相同

var a = [1,2]; 
0

這將創建一個空的字典的目的。

var applicationtypes = {}; 

// Now you can do things like 

applicationtypes['hello'] = 'World!'; 

// or equivalently 

applicationtypes.hello = 'World!'; 
0

在Javascript中:

var applicationtypes = {};相當於var applicationtypes = new Object();

所以它是創建一個空的對象。