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

158
Views
Does "data property" have "access property" internally in javascript?

I understood that there are two types of property in object, data property and access property.

And we can access to "data property" without "access property" like this:

const person = {
  name: 'Pecan'
};

console.log(person.name) // getting name data property
person.name = 'Pie' // setting name data property

And I guess, when data property has created, access property has created internally with the "name" like this:

const person = {
  name: 'Pecan',

  get name() {
    return this.name;
  },
  set name(name) {
    this.name = name;
  }
}

Am I right?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

And I guess, when data property has created, access property has created internally

No, you're not right. A data property does not contain a getter/setter. And an accessor property does not contain a space to store a value. It's either one or the other, it's not like data properties are a layer over accessor properties or the other way round.

It might help to use Object.getOwnPropertyDescriptor to see what the two different ways of writing that object literal generate:

const personData = {
  name: 'Pecan',
}

let personAccessorName = 'Pecan';
const personAccessor = {
  get name() {
    return personAccessorName ;
  },
  set name(name) {
    personAccessorName = name;
  }
};

console.log('data property', Object.getOwnPropertyDescriptor(personData, 'name'));
console.log('accessor property', Object.getOwnPropertyDescriptor(personAccessor, 'name'));
div.as-console-wrapper { max-height: 100%; }

about 4 years ago · Juan Pablo Isaza 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!