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

95
Views
Deconstruct Object into Array of custom variable names

The idea, not a valid code, inspired by this answer:

const source1 = {x1: -5, y1: -5, x2: 10, y2: 10};
const source2 = {x1: 15, y1: 15, x2: 20, y2: 20};

// the ['s1x1'] expression becomes the variable name and x1 as its value
const [['s1x1']: x1, ['s1y1']: y1, ['s1x1']: x2, ['s1x1']: y2] = source1;
const [['s2x1']: x1, ['s2y1']: y1, ['s2x2']: x2, ['s2y2']: y2] = source2;

// use the new variables
let result = s1x1 * s2x1;

Questions

  • Is there a way to to deconstruct object into custom named variables?
  • Does it make sense in terms of performance?
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!