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

716
Views
Move this array "sort" operation to a separate statement. angular 10

t get this message : 'Move this array "sort" operation to a separate statement'

if (isDefined(this.#Type.externalControls)){
  this.#Type.externalControls = this.#Type.externalControls.sort(sortFn);
  this.#Type.externalControls.forEach((control: ITypeControl) => {
    externalForm.push(new FormControl(control));
  });
}

please help me to resolve the issue.

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

0

What .sort does is, it sorts the array it's called on in place, and then returns that array. Assigning the return value of .sort to a new variable could well cause confusion, because now you (may) have two references to the same exact (now sorted) array, rather than a reference to a sorted array and a reference to an unsorted array.

That is

const arr = getArr();
const sortedArr = arr.sort();

is confusing, because arr === sortedArr.

The warning is telling you to not use the return value of .sort, to avoid confusing yourself. Change

this.#Type.externalControls = this.#Type.externalControls.sort(sortFn);

to

this.#Type.externalControls.sort(sortFn);
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!