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

218
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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