The difference between a string and a string literal

Please, can anyone help explain the difference between a string and a string literal?

“Literal” simply means that it’s the value itself, rather than a variable.

For example:

const dog = 'Santa’s Little Helper';

Santa’s Little Helper is a string literal, whereas dog isn’t.

1 Like

Ok. I am getting it. Thank you.

Refer to this aswell.

1 Like

I have gone through the article. It was helpful. Thanks.

1 Like

Lionel is right, that is what is meant by a “string literal”.

And Emgo-Dev is right, that there is also something called a “template literal” that relates to strings and is part of ES6, and might mistakenly be referred to as a “string literal”. They are string literals with the added feature of allowing some light templating.

1 Like