Solved

Javascript hasOwnProperty usage

Posted on 2013-11-14
4
248 Views
Last Modified: 2013-12-10
I've seen hasOwnProperty used as:

if(elem[x].hasOwnProperty){

....
}

Open in new window


I was wondering how this worked and what this if statement was checking since I thought "hasOwnProperty" needed to be followed by a variable inside parantheses.  

Thanks in advance
0
Comment
Question by:Latitude34
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 39648270
Actually what yhe is testing is whether hasOwnProperty exists. A Javascript prior ro 1.5 would return false or undefined.

Cd&
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39648421
according to here the value with the parenthesis is required.

this doesn't seem to be valid JS
0

Featured Post

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Find out what you should include to make the best professional email signature for your organization.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question