What is the purpose of the quotation marks | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the purpose of the quotation marks

15th Nov 2019, 7:29 AM
Akorfa Dagadu
Akorfa Dagadu - avatar
3 Answers
+ 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 :)
15th Nov 2019, 12:12 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 2
Quotations are used for declare string values. Specially in javascript it helps to recognize the value's datatype
17th Nov 2019, 6:19 AM
Rusira Vindiya
Rusira Vindiya - avatar
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
15th Nov 2019, 12:34 PM
Akorfa Dagadu
Akorfa Dagadu - avatar