Could someone please explain this to me?

Could someone please explain this to me?
0

#1

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?


#2

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
}

#3

Thank you very much. :slight_smile: