1

I'm creating an object runtime:

var myObj = {};
myObj[propertyName] = propertyValue;

propertyName is something variable, and if it's like "a.b" my object has the "a" property with the "b" subproperty. So I was thinking about a regexp to clean the data, but I need to know what others characters may be problematic for javascript.

Stefano Vercellino
  • 353
  • 1
  • 6
  • 17
  • 4
    `myObj["a.b"]` create a property called `a.b` . it's not recursive . – Hacketo Oct 30 '15 at 10:45
  • 2
    Possible duplicate of [What characters are valid for JavaScript variable names?](http://stackoverflow.com/questions/1661197/what-characters-are-valid-for-javascript-variable-names) – Hacketo Oct 30 '15 at 10:47

1 Answers1

1

You know if you create it with bracket notation, myObj['a.b'] is a valid single property of myObj object.

Here is your reference:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#Objects_and_properties

Charlie
  • 22,886
  • 11
  • 59
  • 90