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

188
Views
"no puedo acceder a la variable antes de la inicialización" si divido el código en una función separada

Encontré varios artículos, tanto aquí en SO como en otros lugares, que mencionan este mensaje de error, pero ninguno que pueda aplicar a mi situación específica. ¿Alguien puede ayudarme a entender lo que está pasando?

Si escribo mi código así:

 selDocument.group_selected = function ($, anchor) { let tmpitems = $(".chkSelectedField:checked"); if (tmpitems.length > 1) { let items = []; $(tmpitems).each(function (a, b) { items.push($(b).val()); }); if (typeof anchor != 'undefined') { items = items.filter(el => el != anchor); } else { anchor = items.shift(); } console.log("57199516 items, anchor", items, anchor);

funciona bien, pero si tomo esos bloques y los divido en su propia función:

 selDocument.group_selected = function ($, anchor) { let tmpitems = $(".chkSelectedField:checked"); if (tmpitems.length > 1) { let retval = selDocument.create_items_array($, tmpitems, anchor); let items = retval.items; anchor = retval.anchor; console.log("57199516 items, anchor", items, anchor); ... selDocument.create_items_array = function ($, tmpitems, anchor) { let items = []; $(tmpitems).each(function (a, b) { items.push($(b).val()); }); if (typeof anchor != 'undefined') { items = items.filter(el => el != anchor); } else { anchor = items.shift(); } return JSON.parse({ 'items': items, 'anchor': anchor }); };

Aparece "No se puede acceder a 'ancla' antes de la inicialización".

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!