EN
JavaScript - is there a dictionary implementation in js? (.NET equivalent)
1 answers
0 points
Is in JavaScript something similar to the dictionary in .Net? For example, how can I implement an array with an indexer?
1 answer
0 points
In JavaScript you can use a regular object like a dictionary.
Practical example:
xxxxxxxxxx
1
var object = {
2
a: 'value 1',
3
b: 'value 2',
4
3: 'value 3',
5
4: 'value 4'
6
};
7
8
console.log(object['a']); // value 1
9
console.log(object['b']); // value 2
10
11
console.log(object[3]); // value 3
12
console.log(object[4]); // value 4
0 commentsShow commentsAdd comment