...

/

The Multiple Methods of Declaring a String

The Multiple Methods of Declaring a String

In this lesson, you will look at how to initialize a string in a single line, as well as how to write a string on multiple lines.

Strings on a single line

The first primitive is the string. A string is made of characters. It can be assigned a single quote or a double quote. A string’s content can be a number but will behave as characters if between quotes. Both single and double quotes are accepted. However, the guideline of the TypeScript project uses a double quote. By the way, TypeScript is written in TypeScript! It means the language itself is written with the language, hence following its guidance is a good idea.

Press + to interact
let w = "Value1";
let x = "this is a string with the value " + w;
let y = 'this is a string with the value ' + w;
let z = `this is a string ${w}`;
console.log(w,x,y,z)

There is also the ...