Associative array with alphabets as keys in JavaScript
javascript
Solution
Here's a quick and lazy way to create the object:
var a = 97;
var charArray = {};
for (var i = 0; i<26; i++)
charArray[String.fromCharCode(a + i)] = String.fromCharCode(a + i);
console.log(charArray);
http://jsfiddle.net/V2B7S/
Problem
I am looking to create a JavaScript object (associative array) with alphabets as keys. What is the best way to accomplish this? Example - ``` obj[a] = 'somevalue' obj[b] = 'somevalue' ... obj[z]= 'some value' ``` Assigning alphabets as keys dynamically.