' '
and " "
used to quote a string literal and represents string (s), whereas a literal without a quote is known as variables (variable name, constant) as an identifier, example
variable = 'Hello'; (Here `variable` is identifier and 'Hello' is string literal) var = "Ho There"
You may ask, what is the difference between ' (single quote)
and " (Double quote)
The difference is that the lines inside "
, if they have a special character, then they need to escape. Example:
Variable = "hi" there "; ---> here you need to avoid the inner line "
, for example
Variable = "hi \" there";
But if you use '
, then there is no need to escape (if there is no unnecessary '
in the string). you can use
var = 'Hello " World"';
Rahul source share