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

455
Visualizações
Does JQuery support Dictionaries (key, value) collection?

Does JQuery support Dictionaries (key, value) collection ?

I would like to set the following data in a structure

[1, false]
[2, true]
[3, false]

with the ability to add, lookup, delete and update.

Any help!

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

No, jQuery doesn't, but Javascript does.

Just use an object:

var dict = {
  "1" : false,
  "2" : true,
  "3" : false
};

// lookup:
var second = dict["2"];
// update:
dict["2"] = false;
// add:
dict["4"] = true;
// delete:
delete dict["2"];
over 4 years ago · Santiago Trujillo Relatório

0

jQuery, no. But JavaScript does. There are only two structures in JavaScript, arrays and objects.

Objects can be used as dictionary, where the properties are the "keys":

var dict = {
    1: true,
    2: true,
    3: false
};

Properties of objects can be either accessed with dot notation, obj.property (if the property name is a valid identifier, which a digit as used above is not) or with array access notation, obj['property'].

over 4 years ago · Santiago Trujillo Relatório

0

You don't need separate dictionary classes, since Javascript objects act as dictionaries. See this:

var userObject = {}; // equivalent to new Object()
userObject["lastLoginTime"] = new Date();
alert(userObject["lastLoginTime"]);

Full article here: http://msdn.microsoft.com/en-us/magazine/cc163419.aspx

over 4 years ago · Santiago Trujillo 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