Trying to understand why the two cross-browser properties of the Javascript Error object, namely the "name" and "message", cannot be found using the "for ... in" method
// error code ... }catch( err ){ // in FF this lists 3 properties for fileName, lineNumber and columnNumber... // but NOT name or message! for(var propertyName in err) { $( '#diags' ).append( 'err property: ' + propertyName + ', value: ' + err[ propertyName ] + '<br>' ); } // this line prints fine: $( '#diags' ).append( 'Error - name:' + err.name + ', message: ' + err.message + '<br>' ); }
Edit
I am asked what the name and message are. These are properties (are they though?), Which all errors have in any browser ... therefore, in the above code, I added an additional line of code that shows that these "attributes" or whatever they are printed.
Edit2
After Mati's helpful answer, I searched a bit. This seems to answer the “validation” question: Is it possible to get non-enumerable inherited property names of an object?
source share