如何在Javascript中找到属性的所有者 [英] How to find the owner of a property in Javascript

查看:99
本文介绍了如何在Javascript中找到属性的所有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,因为我最初的问题听起来不太清楚,所以我决定编辑它。我的问题是你如何找出谁定义了某个属性,例如 parseInt 函数,我如何知道它被定义的对象,如果 parseInt 窗口对象或文档对象或其他任何对象上定义是什么?谢谢

Ok, because my initial question sounds unclear, so I decided to edit it. My question is how do you find out who defined a certain property, for example, the parseInt function, how do I know on which object it was definded like if parseInt was definded on the window object or the document object or whatever object it is? Thank you

我知道 parseInt 被定义为窗口对象,我一般只是用它作为一个例子,我没有具体询问什么对象定义 parseInt 属性。

I know the parseInt was definded the window object, I am just using it as an example in general, I am not specifically asking what object definded the parseInt property.

另外,请不要告诉我jQuery代码,因为我不知道jQuery非常好。

Also, please don't show me jQuery codes since I don't know jQuery that very good.

推荐答案

遗憾的是,没有办法确定使用代码变量环境是给定变量的。

There is unfortunately no way to determine using code what the variable environment is of a given variable.

对于对象属性,如果它们是 myObj.property ,它们应该是显而易见的。如果不是很明显,可以使用详尽的搜索来查找它们在某些地方的存在,或者某些已知的递归。

As for object properties, they should be obvious if they are myObj.property. If not obvious, it could be possible to use an exhaustive search to look for their existence in certain places, or certain known recursively.

总的来说,不可能知道没有查看实施文档。

Overall, it is not possible to know without looking at implementation documentation.

这篇关于如何在Javascript中找到属性的所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆