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

61
Views
object to String modification in javascript

i got object like this.

Object {
  "company": "984",
  "id": "1",
}

i want to access company and id individually.

The result should look like this

"984"
"1"

How can i achieve these?Thanks.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can write the following function:

let obj = {
  "company": "984",
  "id": "1",
}

let printObject = function(obj) {
    let props = Object.getOwnPropertyNames(obj)
    props.forEach(el => {
        console.log('' + el + '--->', obj[el]);
    });
}

printObject(obj);

about 4 years ago · Juan Pablo Isaza Report

0

Object.values will give you an array of the values

const obj = {
  "company": "984",
  "id": "1",
};

console.log(Object.values(obj));

You can of course assign this array to a variable and then access the values individually

const vals = Object.values(obj);
console.log(vals[0]); /// "984"
console.log(vals[1]); /// "1"
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!