Sunday 2 September 2018

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

hasOwnProperty() method returns a boolean indicating whether the object has the specified property as own (not inherited) property.


In given case -


  testObject = {a: undefined};
testObject.hasOwnProperty('a') //true
testObject.hasOwnProperty('b') //false

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...