+ 1
What is the purpose of the quotation marks
3 Respostas
+ 2
Akorfa Dagadu
I can just assume that you are asking this in context to "javascript objects" (you joined js course and tag is object)
Not an expert of js but from my limited knowledge I know that,
Javascript objects can be defined as set of `key` & `value` pairs.
For example
let John={
age:25
};
console.log(John.age);
//`John` is object `age` is key or property and `25` is value.
But if you have a property name with more than one word like
`eye color` it'll not work unless you quote it.
let Roman={
"Eye color":"Blue"
}
console.log(Roman["Eye color"]);
See how property is quoted and also note that you can use dot notation for accessing properties in this case you need to use brackets and put property as string inside it.
Endnote :
Any quotes will work ` ` , " " , ' '
You can quote property even if it's single word.
as said by Ace it's used for strings normally.
like "Blue" in case of `Roman`.
Please post your question with clear description next time :)
+ 2
Quotations are used for declare string values. Specially in javascript it helps to recognize the value's datatype
0
Thank you all for your answers
To Ace, I am learning JavaScript and how to introduce object in particular.
I was confused as to why some words were in quotation marks in the examples presented.
I even removed them and ran the code but there was no effect. The result was still the same.
That is why I wanted to know why the quotation marks are introduced