DEV Community

Cover image for Underestanding Types of Quotes In JavaScript and Their Uses.
Kenechukwu Nwobodo
Kenechukwu Nwobodo

Posted on

Underestanding Types of Quotes In JavaScript and Their Uses.

This article could be very useful to beginners or maybe even junior developers that makes use of Javascript to write their codes.

Yeah, don't ask me if am a pro, cuz I am not.😄 I did better get started before I end up writing upto 200 lines in this short insight am about to reveal to someone today.

Alright so, I would love to say that they are three types of quotes, oh yeah atleast for now, incase you happen to know any other one, pls kindly drop as a comment.

These quotes includes:
° Double quotes i.e ""
• single quote i.e ''
And lastly, we have,
Guess ? It out☺️, eerhm don't worry it's right below.

•Backticks ``
Permit me to share d this short story before I continue.
The main reason why I decided to share this article was because of the last type of quote mentioned herein - the backticks.
When I started learning programming, I never took cognizance of it. It was actually a knowledge, I passed by but am happy that I have across it and eventually learnt it's functionality and scope.

Alright, I think I have to continue now. Okay, so basically the double quotes and single quotes are used to enclose strings in Javascript. Both does the same work actually. For example, the variable name is assigned with a string, Kenechukwu and it's enclosed with a single quote.
single quote Javascript code

This is exactly the same with the same string enclosed with a double quote as seen below. Both of them will produce the same outcome.
string with double quotes in Javascript

And then lastly, we will talk about the backticks, which are used to embed a strings with Javascript variables as seen below.
Screenshot of basic Javascript code

Yeah, don't forget I told you this is gonna be a short article. If they are more quotes used in Javascript that are no here, pls feel free to comment.

I am just a dude revising and sharing my Javascript knowledge.

Thank you for reading!

Top comments (2)

Collapse
 
octaneinteractive profile image
Wayne Smallman • Edited

I remember the first time I came across Javascript variables and it was welcome to see something similar to what PHP does.

As an example, in PHP single and double quotes have different behaviours, in that: "Hello $userName!" would render the variable, whereas: 'Hello $userName!' would — if I'm remembering this correct — render the variable name as its string value:

Hello $userName!

Collapse
 
kene_nwobodo profile image
Kenechukwu Nwobodo

Yeah