Get file property via hasOwnProperty

I have an HTML5 file upload / dropzone dialog that will give me something like this:

event.dataTransfer.files

      

Now I can see that there are some (required?) Properties for every File object:

https://developer.mozilla.org/en-US/docs/Web/API/File

how file.name

, file.lastModifiedDate

and so on. I can get the values ​​this way

event.dataTransfer.files.item(0).name

      

but DO NOT check if the property actually exists this way:

event.dataTransfer.files.item(0).hasOwnProperty('name')

      

I found out that it hasOwnProperty()

is good practice to check properties for existence with a help , but it doesn't work. Why is this so? Is it because file.name is somehow "required"? But why is the value stored somewhere in the prototype chain?

+3


source to share





All Articles