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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:04:31+00:00 2026-06-15T11:04:31+00:00

Some projects use Object.create() or Object.defineProperties() function. I wonder is is recommended? Whats the

  • 0

Some projects use Object.create() or Object.defineProperties() function. I wonder is is recommended? Whats the difference between

x = Object.create(null); 

vs

x = {}

And

x = {}
x.__proto__.hello = function() { 
    console.log("hello"); 
}

vs

x = Object.create(null);
Object.defineProperty(x, "hello", { 
    value: function() { 
        console.log("hello"); 
    } 
});

defineProperty/create seems very verbose and long to me. When/Why do I use them? Perhaps the good might be to enforce getters/setters/overriding properties?

  • 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-15T11:04:33+00:00Added an answer on June 15, 2026 at 11:04 am

    There is a huge difference. Have a look at the docs!

    • Object.create does create an Object that inherits from the first argument, null in your case. In contrast, {} – or new Object() – creates a new object that inherits from Object.prototype.
    • __proto__ is non-standard and should not be used. However, in your case you just do Object.prototype.hello = function() {…};. Never extend that object with enumerable properties, never ever!
    • Object.defineProperty does define a property on an object with a special descriptor object. The enumerable, configurable and writable attributes default to false, which means that you wont be able to delete x.hello for example, or assign any other value.

    Your first snippet creates a plain object, which inherits a hello method from Object.prototype, while your second snippet creates an object inheriting from nothing and having a non-editable hello property. I don’t see much relatedness.

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

Sidebar

Related Questions

I use Eclipse to study some open source projects on Android. I keep seeing
I use svn:externals to reference several open source projects. I then make some local
Some projects are so big that in order to understand for example a function
Recently I've seen some C# projects that use a double-checked-lock pattern on a Dictionary
Can I create relationships between my object stores in IndexedDB? For example, I have
I have some code I always use to make collections of my object. This
Normally I create web application projects and use code-behind, but I have a requirement
I use MPLAB X (sometime MPLAB 8) and i get some project to finish.
I need to use some classes inside the app_code folder of a website project
As part of my project I need to use some Unamanged code dlls in

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.