Strings

Strings are available in both JavaScript and TypeScript. They are used to represent textual data. This data appears in programs as string literals. These literals are easily identified in most programming languages because of the wrapping double quotes ("").  In JavaScript (and TypeScript), the literals are represented with both double quotes ("") and single quotes (''):

let text: string = "Hi, I am a string. Now you know!";

In the preceding snippet, the text variable stores this string: "Hi, I am a string. Now you know!". Because TypeScript supports the latest features of JavaScript, you can use the new ES6 template literal:

const outro: string = 'Now you know!';let text: string = `Hi, I am not just a simple string. I am actually ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.