Vladimir Kornea Vladimir Kornea - 1 year ago 88
Javascript Question

Why isn't the FileList object an array?

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

Why is

an object rather than an array? The only property it has is
and the only method it has is
, which is redundant (
fileList[0] === fileList.item(0)

Answer Source

Well, there could be several reasons. For one, if it were an array, you could modify it. You can't modify a FileList instance. Secondly but related, it could be (probably is) a view onto a browser data structure, so a minimal set of capabilities makes it easier for implementations to provide it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download