Internet explorer is generating this error for the code that follows:
SCRIPT5007: Unable to get value of the property '0': object is null or undefined
for "document.getElementById('files').files[0]“
It’s correct that …files[0] is null, but I don’t care, how can I tell IE not to care?
Thanks
This will short-circuit and return
undefinedif files is undefined, otherwise it will return the first file.Point of clarification, the error indicates that
filesis the undefined variable and accessing the property0is causing an error. If it werefiles[0]itself, the expression would just returnundefined.