I’m curious about how it is working this structure. When I’m accesing the navigator.mimetypes from Javascript I’m accesing an object.
>>> typeof(navigator.mimeTypes)
"object"
That object has list of objects.
navigator.mimeTypes[Object_0, Object_1, Object_2, …]
>>> typeof(navigator.mimeTypes[0])
"object"
For example, I can retrieve the first object:
navigator.mimeTypes[0]
MimeType { constructor=MimeType, enabledPlugin=Plugin, type="application/x-vnd.google.update3webcontrol.3"}
Can anyone explain me why this is working?
>>> navigator.mimeTypes["application/x-shockwave-flash"]
MimeType { constructor=MimeType, type="application/x-shockwave-flash", description="",more...}
I mean why I am able to find the specified object by means of [“application/x-shockwave-flash”] ??
javascript will be a new world to me 🙂
navigator.mimeTypesreturns an object calledMimeTypeArrayit’s not a traditional JavaScript array but an object that had Array like properties, you can access it’s properties either by index or name.edit: When you use
navigator.mimeTypes['someType']you’re treating theMimeTypeArraylike a hash map, that hassomeTypemapped to aMimeTypeobject in the array that also has atypeproperty of the same value as the key. This is a strange object in the DOM (not technically JavaScript) and you don’t typically see many objects like this.