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

122
Views
Class field name from dynamically concatenation

I try to dynamically use class field name, not a just dynamic var

I have a class like:

class Foo{
  constructor(){
    var papper = "just a papper";
    var crumpled_papper = "this is crumpled papper";
  }
}

Then create new object like:

var bar = new Foo();

And somewhere in my code I wanna to get access some "type of papper", but beforehand I don't know crumpled it or not. For crumpling status I have a new var is_crumpling = "", it can be empty double quotes ("") or has value ("crumpling_");

For get acces to my class var and get message I use:

bar.crumpled+"papper"

but JS execute it like bar.undefinedpapper (instead of bar.crumpled_papper or bar.papper) and I understand it, but how in this case i shold dynamicly call class var name?

P.S. eval also does not work, because bar.eval is not a function

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!