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

182
Views
Get undefined when trying to access object in array

inside es6 class constructor i call a function that returns successfully an array of two objects

But, when i try to access one of those objects i get undefined

here is the log ...


console.log(images) gives

Array [] ​ 0: Object { _id: 118, index: 0, _batchingTransformChange: false, … } ​ 1: Object { _id: 130, index: 0, _batchingTransformChange: false, … } ​ length: 2 ​ : Array []


And console.log(images[0])

images[0] undefined

constructor code

constructor(snapWidth, blockPositioning, config = {}) {

    if (!Object.values(BlockPositioning).includes(blockPositioning)) {
        throw 'Parameter blockPositioning is not supported!';
    }

    super(config)

    this.#snapWidth = snapWidth

    this.somevalue = 7

    this.#blockPositioning = blockPositioning

    let images = this.#addActionImages()

    this.addActionImg = images[0]
    this.removeActionImg = images[1]

    console.log('images ', images)

    console.log('images[0] ', images[0])
    console.log('images[1] ', images[1])

    console.log('this.addActionImg ', this.addActionImg)
    console.log('this.removeActionImg ', this.removeActionImg)
}
about 4 years ago · Juan Pablo Isaza
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!