I get some data from the server with variables that are not valid in Javascript.
Example : Short_%
Is there a way to turn it into a valid one ?
Also, related question : how do I call such a variable name ?
THis : myObject.Short_%
won't work.
I get some data from the server with variables that are not valid in Javascript.
Example : Short_%
Is there a way to turn it into a valid one ?
Also, related question : how do I call such a variable name ?
THis : myObject.Short_%
won't work.
It is possible to use Short_%
as name, the difference is how to access this value. Use the square bracket syntax to set/get a value:
var myvalue=myObject['Short_%'];
An object property name can be any valid JavaScript string, or anything that can be converted to a string, including the empty string. However, any property name that is not a valid JavaScript identifier (for example, a property name that has a space or a hyphen, or that starts with a number) can only be accessed using the square bracket notation. This notation is also very useful when property names are to be dynamically determined (when the property name is not determined until runtime)