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

103
Views
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 answers
Answer question

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 Report

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 Report

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 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!