typeof(nonexistingobj)
returns 'undefined' BUT
typeof(nonexistingobj.nonexistentproperty)
does not generate 'undefined' as I was expecting, but something called a Reference Error - how do I detect this?
I'm trying to do sub-property detection on the response from an API. (Specifically, the API returns a sub object called data.paging.next when there's another page of API results to get, but no 'next' sub object if it just returned the last page).
objdoes not exist (so it's undefined). You can detect this by checking"undefined" === typeof(obj)typeofis an operator, not a function. You use it liketypeof obj.nonexistentproperty.