Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:23:19+00:00 2026-06-11T17:23:19+00:00

In Javascript to find all the values in a hash I have seen the

  • 0

In Javascript to find all the values in a hash I have seen the following code:

var myHash = {};
myHash['one'] = 1;
myHash['two'] = 2;
for (var key in myHash) {
    if (myHash.hasOwnProperty(key)) {
        //do something
    }
}

What is the point of having the hasOwnProperty check here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:23:20+00:00Added an answer on June 11, 2026 at 5:23 pm

    The point is to make sure that key is a property defined directly on myHash and not one that was inherited through a prototype chain. Using in doesn’t automatically filter out inherited properties, so you get to do it yourself.

    But, as others have said, it isn’t necessary for your particular example.

    Source: hasOwnProperty on MDN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know zero javascript, and have one simple task: Find all text in the
i have this code in javascript a= Excel.Workbooks.open(C:/work/ind12.xls).ActiveSheet.Cells.find(value); if(a == null) document.getElementById('dateValid').innerText = Date
I have a dropdownlist with two values: Sponsor and Social_Worker. All I want to
I have a page in which I want to find all datetime values. I
In some javascript, I have: var url = find.aspx? + location= + encodeURIComponent( address
This javascript will find all my selects and validate them but I want to
I am supposed to write a program in JavaScript to find all the anagrams
I am trying to store the values inside a javascript object notation. I have
I'm looking to find the Javascript Event I need to put into jQuery's .bind
Copied from my log file ActionView::Template::Error (Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.