Assuming I declare
var ad = {};
How can I check whether this object will contain any user-defined properties?
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.
You can loop over the properties of your object as follows:
It is important to use the
hasOwnProperty()method, to determine whether the object has the specified property as a direct property, and not inherited from the object’s prototype chain.Edit
From the comments: You can put that code in a function, and make it return false as soon as it reaches the part where there is the comment