I have defined an object with properties that have hyphen in their names.
var data = {
"foo-bar": "value",
"this-that": "another value"
}
Now I need to reference this property in JS, but both these ways result in syntax error.
console.log( data.foo-bar )
and
console.log( data."foo-bar" )
So my question is. How can I access a property that contains hyphen in the name in JS?
Disclaimer: The server-side functionality require hyphen-naming of the properties and I don't really feel like rewriting somebody else's whole script that takes the input params like this. And yes, I know this current way is not the most clean approach possible.