liveBook · Manning

String

As explained in Pro Angular 16

A string is a JavaScript primitive value representing a sequence of characters.

A string is a JavaScript primitive value representing text as a sequence of characters. Define strings with matching single or double quotation marks; mismatched quotes are invalid. JavaScript also supplies string properties and methods for inspecting, searching, changing, and splitting text. section 3.4.6

Use strings for these common tasks:

  • Read text with length and charAt(index). section 3.4.6
  • Combine values with concatenation or concat(string). section 3.4.6
  • Search and transform text with indexOf, replace, slice, split, and related methods. section 3.4.6
  • Insert values inline with template strings, using backticks and ${value} expressions. section 3.4.6

Literal strings and template output

let firstString = "This is a string"; let secondString = 'And so is this'; let place: string | undefined | null; console.log(`Place value: ${place} Type: ${typeof(place)}`); The template string produces: Place value: undefined Type: undefined. section 3.4.6

String coercion in JavaScript

function myFunction(param) { let result = param + 100; console.log("My result: " + result); } myFunction("London"); JavaScript converts 100 to a string, producing London100. A typeof check can reject unexpected values at runtime. section 3.4.2

How Pro Angular 16 covers it

How deep it goes
Explains literals, interpolation, coercion, and common methods through examples without descending into string internals.
Examples
Demonstrates quoted literals, London100 coercion, template interpolation, and a table of common string methods.
What you can do after
Apply string literals, concatenation, template interpolation, common methods, and runtime type checks in JavaScript and TypeScript.
How it connects
Connects strings with primitive types, string concatenation, template strings, typeof checks, and TypeScript type annotations.

Also explained in

Compare how 24 books explain string →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro Angular 16. The section links point to the parts of the book it draws on.