我必须将属性(动态)分配给一个对象,并动态删除它们。
我使用:
var data_to_filter = new Object();
Object.defineProperty(data_to_filter, 'country', {
value: pais_f, // pais_f, variable
writable: true, // readonly
enumerable: true,
configurable: true // do not allow re-configure the peroperty
});
console.log(data_to_filter);
当我通过控制台显示对象时,它是完美的({country: "Brazil"}),但是当我想删除一个属性时,它看起来好像不存在。
delete data_to_filter.country;
(Property 'country' does not exist on type 'Object')
感谢您的帮助