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 7527625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:09:06+00:00 2026-05-30T04:09:06+00:00

In response to a previous question, I received this helpful answer : for (var

  • 0

In response to a previous question, I received this helpful answer:

for (var i in someArray) {
    if ({}.hasOwnProperty.call(someArray, i))
        alert(someArray[i]); 
}

My questions are:

  1. Where can I read about the {} construct? I cannot find it in the jQuery docs, and it is impossible to google for.

  2. Where can I read about the call() function. Searching the jQuery API site does not turn up anything seemingly related.

Thanks.

  • 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-05-30T04:09:08+00:00Added an answer on May 30, 2026 at 4:09 am
    1. {} is one way to declare an empty object. It is called object literal syntax and you can read more about it here.

    2. The call() method is a JavaScript method (not jQuery). Again, you can read more about it here. Basically, call() allows you to change the value of this inside the function you’re calling call() on. It is related to apply();

      var array = new Array;
      
      function foo() {
          alert(this === array);
      };
      
      foo(); // false;
      foo.call(array); // true
      

    Looking at the code in particular, we’re looping over an array and using the hasOwnProperty method to check the value (i) exists on the someArray array (as opposed to being in the prototype chain of someArray.

    As for why we’re using {}.hasOwnProperty as opposed to someArray.hasOwnProperty, I guess that the user might be protecting against hasOwnProperty being declared on someArray (by using an empty object). If he hadn’t done this, then the following could have been possible;

    var someArray = [];
    someArray.hasOwnProperty = function () { 
        return true; // always return true... muahahaha.
    }
    

    Or even;

    var someArray = [];
    someArray.hasOwnProperty = 4; // now hasOwnProperty isn't even a function. Calling someArray.hasOwnProperty() will result in an error.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is in response to my previous question: PowerShell: -replace, regex and ($) dollar
Thanks to Insin for answering a previous question related to this one. His answer
In @mmalc's response to this question he states that In general you should not
Based on the response to this question: Why does C++ have header files and
This is an attempt to rephrase my previous question as a result of the
This is a follow up to a previous question that I had before about
So thanks to the response to my previous question , I've tried to make
This is a follow up question to my previous question . I am trying
this is a follow up question of my previous question So I have this
This is a follow up on my previous question . I set up the

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.