Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

133
Vistas
how to loop inside '' in javascript

I want to loop inside single quote I have nested loop in my code errors occurs when I try to loop inside the quote

var jsonObj = @json($data);
var borFld = Object.keys(jsonObj);
var all_fields;
var fields_remove = []
var table_id = @json($table_id);

var rows = [];
var htmls = [];
function getFields(){
    var my_fields = [];

    for(keys in jsonObj){
        var item = jsonObj[keys];
        var fields = Object.keys(item)

        htmls +=
        '<tr>'+
            for(list in fields) {
                var myfields =   fields[list]
                all_fields = item[myfields]

            }
        '</tr>'
    }
   // $('#tb_time_sheet tbody').html(htmls)

}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I guess you get the data as string of JSON object. You should first parse it so that JS can read it.

const parsedJsonObject = JSON.parse('{"name":"Test"}');

After that you can use it inside for loop. If it is not array of object and key value pair

  1. You can get values by:

    Object.values(parsedJsonObject);

  2. You can get keys by:

    Object.keys(parsedJsonObject);

Then, iterate over keys and get value by:

parsedJsonObject[key]
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda