I wonder if there is any difference between using "" or not with JS objects
With "":
var object = {
"prop1": 1
"prop2": 2
"prop3": 3
}
vs.
Without "":
var object = {
prop1: 1
prop2: 2
prop3: 3
}
I wonder if there is any difference between using "" or not with JS objects
With "":
var object = {
"prop1": 1
"prop2": 2
"prop3": 3
}
vs.
Without "":
var object = {
prop1: 1
prop2: 2
prop3: 3
}
No difference from JavaScript point of view. These two declarations are equivalent to each other.
Both would work most of the times.
The main issues with this are:
To produce valid JSON, you need to use double qoutes (even a single quote is techncially not standard).
Sometimes you would use property names that would require you to use qoutes. So for example "my-prop".
var object = { "prop1": 1, "prop2": 2, "prop3": 3 }
The above object is a proper JSON.
var object = { prop1: 1, prop2: 2, prop3: 3 }
This is a simple javascript object.