javascript - Is there any way to distinguish between an unset property and a property set to undefined? -


this question has answer here:

say have object testobject = {a: undefined}. if console.log(testobject.a), undefined. same happens if console.log(testobject.b), doesn't exist. there way in javascript distinguish between a , b here? ask out of curiosity, have no use case.

hasownproperty() method returns boolean indicating whether object has specified property own (not inherited) property.

in given case -

  testobject = {a: undefined};    testobject.hasownproperty('a') //true   testobject.hasownproperty('b') //false 

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

c# - Update a combobox from a presenter (MVP) -

android - Unable to generate FCM token from dynamically instantiated Firebase -