I would like to use create a object that contains regular expressions as the key value. I tried to use the following syntax:
var kv = {
/key/g : \"value\
Object keys cannot be RegExp objects. You must use a string or a valid ID. That being said, you could do something like this:
var kv = {
"/key/g": "value"
};
I'm curious. Why do you want to do this?
EDIT: I am partially mistaken. RegExp objects can be used as keys, but not using the object literal syntax. See jmar777's answer.