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

174
Views
Function return in nested object

This is normal look for my code. This is simple resource used later in canvas and this works.

var myObject = {
 resourceAnim: new Resource("images/loop-images/", 20, true),
}

Now I need to check somevar and make logic branch.


var myObject = 
  resourceLoop: () => {
    if (somevar == 0) {
      return new Resource("images/loop-images/", 20, true),
    } else {
      return new Resource("images/loop-images/", 50, true),
    }
  }

}

But this is not the same. Any suggestion for nested object structure?

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

0

Why not use a ternary operator?

var myObject = {
  resourceLoop: somevar == 0 ? new Resource("images/loop-images/", 20, true) : new Resource("images/loop-images/", 20, true),
}
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!