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

155
Views
¿Cómo arreglar "push no es una función"?

Estoy tratando de crear un botón de eliminación para eliminar filas de elementos de una tabla, pero me encuentro constantemente con un "Error de tipo no detectado: deleteArr.push no es una función". No estoy seguro de qué hacer. Aquí está el código:

 //Remove buttom $(document).ready(function() { // As soon as jquery loads, load from storage // it will return null if nothing is stored yet const deletedExpenses = JSON.parse(localStorage.getItem('deletedExpenses')) || []; $('body').on('click', '.deleteButton', function(e) { e.preventDefault(); // prevent the href default // if you need to access the id... let deleteID = $(this).data('id'); $(this).closest('tr').remove(); // You first have to load from storage the array of deleted items, var deletedArr = localStorage.getItem("deletedExpenses"); // If you have nothing stored, this will return null, // And if that's the case, create new array if (!deletedArr){ deletedArr = []; } // then push to this array another ID that got deleted deletedArr.push(deleteID); localStorage.setItem('deletedExpenses', JSON.stringify(deletedArr)); })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto establece la variable en una cadena:

 var deletedArr = localStorage.getItem("deletedExpenses");

Cuando establece el valor de almacenamiento local, lo codifica en JSON, por lo que debe analizarlo desde JSON al leerlo:

 var deletedArr = JSON.parse(localStorage.getItem("deletedExpenses"));
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!