I have some characters as object keys in an object like:
Those are actually icons, and I want to replace one icon with the other.
And my icons object is laid out like this:
icons = {
: {old: , new: },
: {old: , new: }
}
How can I search for the icon? When I try to search, I get an invalid character error.
CodePudding user response:
When you declare your object
, put quotes around the keys:
const icons = {
"": { ... } // and so on
};
Then you can access it using the bracket notation:
icons[""]