简体   繁体   English

如何在JavaScript中识别对象的方法和属性

[英]How to identify methods and properties of an object in javascript

如何在javascript中识别对象的方法和属性?每个对象有多少方法和事件?

If you using Google browser make use of the console window. 如果您使用的是Google浏览器,请使用控制台窗口。 Enter the valid object and you may find a drop-down button which enlists all the methods and its respective properties registered to it. 输入有效的对象,您可能会发现一个下拉按钮,其中列出了所有方法及其向其注册的各个属性。

You can easily know what are Object keys and then you can also get their perticular value 您可以轻松了解什么是对象键,然后还可以获取它们的垂直值

Object.keys(yourObj) Object.keys(yourObj)

if you know the property and want to check whether it exists in your object or not then 如果您知道该属性并想检查它是否存在于您的对象中,则

youObj.hasOwnProperty("propName") youObj.hasOwnProperty( “PROPNAME”)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM