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

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

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 Report

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 Report

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