Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

105
Visualizações
How to get all values in a data table

I am trying to get all the values in a JavaScript data table but whenever I try it says, "table.length is not a function" or, "table.size is not a function" (I've tried both).

Here is the code I want to use:

const wordcount = {"this", "is", "a", "data", "table"}

console.log(wordcount.size()) // wordcount.size is not a function

I want it to return an integer value to the console. How would I do this?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

In the first line, Object's type is not true.

If you want to loop object, here is sample code.

// Object Loop
const wordcount = {
    key1: "this", 
    key2: "is", 
    key3: "a", 
    key4: "data", 
    key5: "table"
}
for (let key in wordcount) {
    console.log(wordcount[key])
}
about 4 years ago · Juan Pablo Isaza Relatório

0

Word count is not an valid array, see the code below it should work fine

const wordCount = ['this', 'is', 'a', 'data', 'table']

console.log(wordCount.length)

An array should always start with this '[' and end with this ']' not with '{'

about 4 years ago · Juan Pablo Isaza Relatório

0

I think I got your question wrong are you trying to make a data table? A data table must only contain primitive values such as string, number, Boolean, null, undefined etc.

// sample code 
const data = {
   name: "Jhon",
   age: 25,
   isChild: false,
 }

Note: size is not a function it is an attribute

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda