String

Probably one of the most widely used primitive types in our code will be the string type, where we populate a variable with a piece of text:

var brand: string = 'Chevrolet';

Check out the type assignation next to the variable name, which is separated by a colon symbol. This is how we annotate types in TypeScript, as we already saw in the previous chapter.

Back to the string type, we can use either single or double quotes, and it is same as ECMAScript6. We can define multiline text strings with support for text interpolation with placeholder variables by using the same type:

var brand: string = 'Chevrolet';
var message: string = `Today it's a happy day! I just bought a new ${brand} car`;
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset