Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
Are these inherited properties?

I am learning about inherited properties and I am pretty confused. I would really appreciate your help to give me some clarity.

So, an inherited property is a property that the object inherits from the prototype object.

An article I read gave an example of an inherited property: "every JavaScript object inherits the toString property from its prototype object"

So, my question is: Are these all inherited properties?

  • Static methods

    Object.assign()

    Object.create()

    Object.defineProperty()

    Object.defineProperties()

    Object.entries()

    Object.freeze()

    Object.fromEntries()

    Object.getOwnPropertyDescriptor()

    Object.getOwnPropertyDescriptors()

    Object.getOwnPropertyNames()

    Object.getOwnPropertySymbols()

    Object.getPrototypeOf()

    Object.is()

    Object.isExtensible()

    Object.isFrozen()

    Object.isSealed()

    Object.keys()

    Object.preventExtensions()

    Object.seal()

    Object.setPrototypeOf()

    Object.values()

    Instance properties

    Object.prototype.constructor

    Object.prototype.proto

    Instance methods

    Object.prototype.defineGetter()

    Object.prototype.defineSetter()

    Object.prototype.lookupGetter()

    Object.prototype.lookupSetter()

    Object.prototype.hasOwnProperty()

    Object.prototype.isPrototypeOf()

    Object.prototype.propertyIsEnumerable()

    Object.prototype.toLocaleString()

    Object.prototype.toString()

    Object.prototype.valueOf()

(I found this list from MDN objects, they are static methods, instance properties, and instance methods of objects, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)

And So, does that mean all objects have the above properties?

And since functions are basically objects, functions also inherited those?

Also, is there a place I can find the list of all the inherited properties objects have?

Thank you so much in advance! sorry for the long post.

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Static methods cannot be inherited, because they exist on the class and not on any instance of a class. So those are out. The other methods, absolutely! At least I think so. Let's run some experiments and check the results.

const f = () => {
    return "hello world"
};
f.foo = "bar";

console.log(f.constructor);
console.log(f.toString());
console.log(f.valueOf());
console.log(f.hasOwnProperty("foo"));
console.log(f.hasOwnProperty("frankincense"));

This snippet indicates that, yes indeed, non-static methods are inherited by functions, because functions are objects... as Crockford rolls in his grave

about 4 years ago · Santiago Trujillo Report

0

The static methods, belong only to the Object class ( constructor function ), that means that you can call them only by doing Object.nameOfMethod().

The instance properties & methods on the other hand, are inherited by all the instances of Object, which means that every object will inherit those props/methods.

Now remember that in JS every entity if it's not a primitive, is an object.

For example an array:

const arr = ["hello"]

console.log(typeof arr)                           // object
console.log(arr instanceof Object)                // true
console.log(Array.prototype.isPrototypeOf(arr))   // true
console.log(arr.propertyIsEnumerable(0))          // true
console.log(arr.toLocaleString())                 // hello
console.log(arr.valueOf())                        // ["hello"]
console.log(arr.hasOwnProperty(0))                // true
console.log(arr.toString())                       // hello

This is because even if arrays in JS are instances of Array, they are also instances of Object, you can see an array as a special object where indexes are keys:

const arr = {
0: "hello"
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!