是否可以在初始化對象文字後向對象文字添加新屬性。我想做類似以下的事情:如何將新屬性添加到對象文字
// Initialize new object literal to hold subset of information about each transaction.
var transactionJson = new {};
transactionJson[transaction.Id] = new {
Status = transactionList.StatusProperty,
Completed = transactionList.Completed,
First = transactionList.First
};
這不是一個對象字面;這是一個匿名類型。 – SLaks 2012-02-03 21:03:09