I have an empty object defined (associative array)
obj = {}
If I try to consult some parameter this will return undefined to me because it is empty.
>> console.log(obj.id)
undefined
now I assign a value to id
>> obj.id = 123
>> console.log(obj.id)
123
Suppose I want to delete the id attribute which of these 2 is more convenient
obj.id = undefined
or
delete obj.id
when I check the independent attribute of which one I used, it will return undefined but if I do console.log()
of just the object I have something different:
For the first case:
>> console.log(obj)
{id: undefined}
On the other hand, for the second case:
>> console.log(obj)
{}
Which is the best, there is another alternative.