JavaScript Benefits of calling hasOwnProperty as a direct static reference with the call method, as opposed to calling it as an object instance method

In numerous JavaScript sources, I have seen a preference of calling Object.prototype.hasOwnProperty from a static reference as in the following example:

var hasOwnProp = Object.prototype.hasOwnProperty;
//...
if ( hasOwnProp.call(myObj, 'prop') ) {
    doSomethingWith(myObj);
}

Why is it preferred over calling an object instance's hasOwnProperty method:

//...
if ( myObj.hasOwnProperty('prop') ) {
    doSomethingWith(myObj);
}
Answer:1

Besides using Object.prototype.hasOwnProperty, we can also use the object literal ({}).hasOwnProperty.call(myObj, 'prop');

Answer:2

I am trying to raise a Javascript confirm box from code behind. I am using the following syntax ScriptManager.RegisterStartupScript(this, GetType(), "key", "javascript:return confirm('Are you sure ...

I am trying to raise a Javascript confirm box from code behind. I am using the following syntax ScriptManager.RegisterStartupScript(this, GetType(), "key", "javascript:return confirm('Are you sure ...

I am trying to visualise "investment value" over "APR" and my data looks like this: 7.4: 2000 7.4: 300 7.9: 1000 8.0: 15000 8.0: 730 8.3: 700 Each line here represents a borrower, who offered to ...

I am trying to visualise "investment value" over "APR" and my data looks like this: 7.4: 2000 7.4: 300 7.9: 1000 8.0: 15000 8.0: 730 8.3: 700 Each line here represents a borrower, who offered to ...

  1. best chart to display outliers and mean
  2. best chart to display performance over time
  3. best chart to display data over time
  4. best chart to display percentages
  5. best chart to display proportion of a multiple components
  6. best chart to display ranking
  7. best chart to display trends over time
  8. best chart to display survey results
  9. best chart to display time
  10. best chart to display data
  11. best chart to display proportion of a single component
  12. best chart to display proportion of a single component in excel
  13. best visual display chart in excel

I’m having trouble accessing nested data via handlebars. I've searched similar questions but none of them involve using the value of 'this' as a property name. Here's the data: var activity_groups = ...

I’m having trouble accessing nested data via handlebars. I've searched similar questions but none of them involve using the value of 'this' as a property name. Here's the data: var activity_groups = ...

  1. d3 accessing nested data
  2. accessing nested json data
  3. python accessing nested json data

In my project, I am trying to add a <br> element inside a element div. So, that I can show ellipsis on second line. Here is the fiddle in which I hardcoded the br tag. <div>hellohel<...

In my project, I am trying to add a <br> element inside a element div. So, that I can show ellipsis on second line. Here is the fiddle in which I hardcoded the br tag. <div>hellohel<...