1

Suppose if a object has parameters var data={"f name":"vishal"} and i want to access parameter "f name" in javascript. I know that there should not be space in parameters of a object but if it has space in it then how can i read it.

2

3 Answers 3

2

Something like this:

data['f name']
Sign up to request clarification or add additional context in comments.

Comments

1

Spaces in attribute names are perfectly OK in JavaScript. You reference them by the

object["param name"] 

syntax. Moreover, any UTF8 character, except for control characters, are valid in attribute names.

Comments

1

Use square bracket notation:

data["f name"]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.