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

216
Views
what is basic difference between the array and objects in the java-script

In using the react i'm not able to understand in which situations we prefer array over objects sometimes we are using objects and sometimes we are using arrays that thing make me little bit confuse

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

0

Objects are mutable data structure in javascript which is used to represent a ‘Thing’. This could be anything like plants, cars, person, community etc.It stores the data in key value pair and the key can be anything except for undefined. The keys are iterable and can be accessed in any order.

We can either use a dot operator followed by key name obj.name or a square bracket along with key in string format obj['name'] to access the value.

const obj = {
  name: 'Shubham Shukla',
  age: '22',
  gender: 'Male',
  getDetails: function() {
    return `${this.name} is ${this.age} years old`;
  }
};

console.log(obj.name);

Arrays are objects only in javascript. The major difference is that they store the data in an ordered collection in which the data can be accessed using a numerical index.They are also mutable and data can be modified at any index. Indexes are zero based which means the first item is stored at Oth index, second at first and so on, last item is stored at n-1th index.

const arr = [22, 17, 34, 45, 78, 67];

console.log(arr[0]);

if you have to store the data in order or in a sequence then use array otherwise you can use object for everything else.

about 4 years ago · Juan Pablo Isaza Report

0

Most of the cases, you're gonna use objects for named items, while array for just a collection of items.

Example which uses both:

var someone = {
  full_name: ['Bob', 'Smith'],
  age: 32,
  gender: 'male
}

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!