Accessing attribute name containing slash in javascript object
javascript, json
Solution
When you enclose the prop name into quotes, it works also in the code:
var obj = {
'my/key' : 'my value'
};
You can check this at jsFiddle.
Problem
Hi I'm trying to access an js object property which has an slash "/" in its name. The object its somthing like: ``` { my/key : "my value" // more stuff here... } ``` I try the following construction: ``` myObject["my/key"] ``` If I try to it in Chrome DevTools it works correctly but when I execute my code i get a beautiful undefined on browser console (using console.log()) has anybody any idea of what's happening? :S