Get object name from ReferenceError

I am curious if there is a way to get the name of the reference object from the caught ReferenceError. For example:

 try{
     foo;
 } catch(e){
     e.message; // "ReferenceError: foo is not defined"
 }

Is there another property containing "foo"? I would like to create something like missing_method in ruby, if possible. Except for variable access, so I'm not worried about losing args / context. This seems to be one of the big blockers.

+4
source share
1 answer

Good question, as far as I know (and if you are checking the console), there is no property / method in the ReferenceError object referring to the missing name.

, . , . , , , Regexp.

+1

All Articles