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

  • Home
  • SEARCH
  • 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 8991445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:43:41+00:00 2026-06-15T22:43:41+00:00

Possible Duplicate: Why is it Object.defineProperty() rather than this.defineProperty() (for objects)? I noticed that

  • 0

Possible Duplicate:
Why is it Object.defineProperty() rather than this.defineProperty() (for objects)?

I noticed that all the methods of a particular object can be called from the actual object instance, i.e., object.method(); or by passing the object to Object.method() as an argument. For example:

var a = ['one', 2, 3, 'four'];
a.reverse();
// OR
Array.reverse(a);

I seemed to get the same behaviour. I was wondering what the difference was and when one would be used over the other?

  • 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-15T22:43:43+00:00Added an answer on June 15, 2026 at 10:43 pm

    Object.method(o) looks on the Object object (Object is a real object in JavaScript) for a property called method and tries to call it passing in the variable o. During the call, this will be Object.

    o.method() looks on the object referenced by the variable o for a property called method and tries to call it, not passing anything in. During the call, this will be o.

    As you can see, they do quite different things.

    I noticed that all the methods of a particular object can be called from the actual object instance…or by passing the object to Object.method() as an argument.

    No, they cannot. Your example Array.reverse(a) fails on a standard implementation of Array because Array doesn’t have a property called reverse and so it can’t be called as a function. Edit: You note in the comments that it works in Firefox’s scratchpad, and I just verified that. That means Firefox’s SpiderMonkey JavaScript engine is applying a non-standard extension to Array which provides a static implementation of reverse. That’s specific to Firefox’s Array, not general to all objects. (If you make your own Foo, for instance, its prototype functions don’t magically get added to Foo as well.)

    The standard way to make the near-equivalent to a.reverse() would be via the prototype, like this:

    Array.prototype.reverse.call(a);
    

    That does work in standard engines. So let’s look at what it does:

    1. It gets the prototype property from Array.

    2. It gets the reverse property from the object it got in #1.

    3. It calls the function that property referenced using the Function#call feature of JavaScript function objects to make this be the argument you pass into call during the course of the function call.

    When you create an array, the object gets an underlying prototype. That prototype is the object referenced by Array.prototype when the new array is created. So a has a reverse property because its underlying prototype has a reverse property.

    Doing a.reverse() does this:

    1. Gets the reverse property from the a object. Since (normally) a won’t have its own property called reverse, standard JavaScript property lookup looks to a‘s underlying prototype. It finds the property there and uses its value.

    2. Calls that function such that this is a within the call.

    As you can see, the end result is the same provided that the underlying prototype of a and Array.prototype still refer to the same object. (It’s possible for them not to, although in the case of Array or any other built-in, if someone replaced [as opposed to augmenting] Array.prototype, that would be a Bad Thing(tm).)

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

Sidebar

Related Questions

Possible Duplicate: Why do this Ruby object have two to_s and inspect methods that
Possible Duplicate: Delete object and all its child objects in Entity Framework? This code:
Possible Duplicate: Sorting JavaScript Object by property value Since I've noticed the browser can't
Possible Duplicate: R help page as object I can do temp <- help('ls') But
Possible Duplicate: declare property as object? in java you can create an object directly
Possible Duplicate: Can you write object oriented code in C? I'm wondering if it's
Possible Duplicate: Can you write object oriented code in C? Hi, can someone point
Possible Duplicate: Javascript: Object Literal reference in own key’s function instead of ‘this’ I
Possible Duplicate: convert object to array Let's say I have an array like this:
Possible Duplicate: TypeError: ‘module’ object is not callable This is my very first Python

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.