As the comments indicate the &
character is illegal as a variable identifier. Additionally, in your example, you also have spaces, which are also illegal in variable identifiers. But both the &
and space characters are acceptable in a property identifier. While you can't have a variable containing these characters, you could have an object property, like this:
var obj = {};
var prop1 = "Books & Cds";
obj[prop1] = "Kids";
You would then retrieve that property value with the same bracket notation used to create it. You can use the variable or you can use the literal value, either way, you must provide a string when using bracket notation:
console.log(obj[prop1]); // "Kids"
console.log(obj["Books & Cds"]); // "Kids"
Not sure if this will work for your use case, but it can be done.
Here's the code above, in a working example:
var obj = {};
var prop1 = "Books & Cds";
obj[prop1] = "Kids";
console.log(obj[prop1]); // "Kids"
console.log(obj["Books & Cds"]); // "Kids"