Is there a function or something to get the interface of an object?
Like, for <p/> = HTMLParagraphElement, how would I retrieve it?
Thanks in advance!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think there are just one way to do so: fetch a list of all available interfaces, iterate via this list and check your variable value for type using
instanceofoperator.This way should work like following:
Now you get something like
function HTMLParagraphElement() { [native code] }in interface variable (if element is<p />). I assume this only works for V8 (Google Chrome). Now you can use regexies to extract interface name.To get list of all interfaces you can use following (works only for HTML elements):
I agree with duri’s answer, so you don’t need to enumerate all interfaces, using of
constructormethod is more easy way to get prototype function. After that you can use regex I wrote to extract interface name.