RCN
Mar 05, 2015, 10:53 PM
Often we have to define new objects.
var obj = { ExtNet: "Object.Net", ExtJS: "Sencha" };
It's possible to define new properties and update existing ones
obj.Gtx = "Sencha";
obj.ExtNet = "Updated";
Result:
{
"ExtNet": "Updated",
"ExtJS": "Sencha",
"Gtx": "Sencha"
}
But it may be required to define a immutable object. It's possible to do that by using Object.freeze.
var obj = Object.freeze({ ExtNet: "Object.Net", ExtJS: "Sencha" });
Hope it helps.
var obj = { ExtNet: "Object.Net", ExtJS: "Sencha" };
It's possible to define new properties and update existing ones
obj.Gtx = "Sencha";
obj.ExtNet = "Updated";
Result:
{
"ExtNet": "Updated",
"ExtJS": "Sencha",
"Gtx": "Sencha"
}
But it may be required to define a immutable object. It's possible to do that by using Object.freeze.
var obj = Object.freeze({ ExtNet: "Object.Net", ExtJS: "Sencha" });
Hope it helps.