I have an object like this.
var v= {
a: 1,
delete: () => delete this.a,
}
I am not able to delete a
after executing v.delete
I have an object like this.
var v= {
a: 1,
delete: () => delete this.a,
}
I am not able to delete a
after executing v.delete
You need convert arrow to function to use this keyword.
Also you did not call delete method to delete property.
var v= {
a: 1,
delete: function () {
delete this.a
}
}
v.delete()
console.log(v)
var v= {
a: 1,
delete: function(){delete this.a}
}
console.log("before=" + v.a)
v.delete()
console.log("after="v.a)
Arrow function doesn't have access to this context of the current object.