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

119
Views
Class object variables reads as "undefined" when accessing from the class or class made object from outside the class

When I try to access a class object variable from outside a class it reads as "undefined"

class Foo {
    constructor (arg) {
        this.arg = arg;
        var bar = {
            a: 'Foo'
        }
    }
}
console.log(Foo.bar);

But it works if I do it inside the class, but I need it outside the class.

class Foo {
  constructor(arg) {
    this.arg = arg;
    var bar = {
      a: 'Foo'
    };
    console.log(bar); //not appearing in the snippet, but it works in a browser
  }
};

about 4 years ago · Santiago Trujillo
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!