Does JavaScript's typeof function check for null -


does javascripts typeof expression check null?

var test = {}; console.log(typeof test['test']);//"undefined"  var test = null; console.log(typeof test['test']);//typeerror: test null 

obviously, why error, if typeof null object?

edit:
know how avoid type error, , null has no properties, i'm wondering there explanation behavior of typeof.

var test = { test: null }; console.log(typeof test['test']);// object 

your code throws exception because reading property of null this:

null['test'] 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -