I'm trying to create a sequence of sound frequencies for a project I'm working on. I'm not too experienced in JavaScript and came across this code that I'm thinking about implementing in my project; the problem is I'm not sure what it does. It looks like a key value function of some sort. Can someone explain this and if it is possible to add multiple values to the "values" part on the right side of the colon?
const freqMap = {
1: 250,
2: 329.6,
3: 398,
4: 462.2,
5: 350,
6: 400,
7: 290,
8: 300,
};
CodePudding user response:
This is called an Object, which is a JavaScript key:value store.
For example, freqMap[1]
will return 250
. You could assign an array or another object: 1: [250, 500]
or 1: { 1: 250, 2: 500 }
.
CodePudding user response:
It really is key value for example
freqMap['1']
or freqMap[1]
will return 250 you can assign array to the value like so
const freqMap = { 1: [250, 300], ... };