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

113
Views
Mostrando el valor predeterminado después de regresar de cada bucle

Estoy tratando de verificar la duplicación de nombres mientras agrego los registros. Inicialmente, he asignado value a false . En caso de que no coincida, el value se cambia a true dentro de cada bucle y sale del bucle. Pero fuera del ciclo, el value nuevamente se muestra como false .

 function IsDuplicated(name) { var value = false; masterTable = $('#example').DataTable(); var form_data = masterTable.rows().data(); $.each(form_data, function (key, value) { alert(value.Name); if (name== value.Name) { value = true; alert(value+ " 1") return false; } }); alert(value+ " 2") return value; }

¿Puede ayudarme por qué está cambiando al valor predeterminado después de regresar de cada ciclo?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Es más limpio si lo hace usando buscar en su lugar

 function IsDuplicated(name) { const masterTable = $('#example').DataTable(); const data = masterTable.rows().data(); return !!data.find(d => d.Name == name) }
about 4 years ago · Santiago Trujillo 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!