Could someone please explain this to me?

why is it that properties inside of objects are declared using quotation marks around the name of the property?
example:
var myObject = {
“name”: “thing”,
“wheels”: 4
}
It seems as though it works the same if there are not quotes around the name of the property
ie:
var myObject = {
name: “thing”,
wheels: 4
}
what is the purpose of the ""s and are they needed in the declaration of objects?

No you don’t need to use quotes. The time you would use quotes is if your keys have a space or special character.
They would be used with

Object={
“An-example”: example
“Another example”:example

Otherwise use quotes if your values are strings. Numbers and arrays don’t need quotes

Object2={
Item: “food”
Number: 4
}
2 Likes

Thank you very much. :slight_smile: