How to access a string “key” in Vue that includes hyphens, spaces or other special characters
2 min readJul 11, 2023
Usually in Vue, you would use the dot .
notation to access a normal key, but when you have a key that has spaces or special characters you need to use the square bracket notation []
instead as the dot notation expects a valid JavaScript identifier as the key, and spaces and special characters are not allowed in identifiers.