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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -