Account
Categories

String


Definition:

If you use the string datatype in your program, it stores string values in a variable.

It stores text, letters, or words in a variable.

Letters, text, or words are written inside quotation marks ("" or '').

When a value is closed with quotes, JavaScript recognizes it as a string.

Syntax:

let variableName = "text";

Example:

let name = "Shobha";
let city = 'Delhi';

Here, "Shobha" and 'Delhi' are string values because they are inside the quotation marks.

Output:

Variable Name              Value
name
---------->
"Shobha"
city
---------->
'Delhi'