Language concepts

String immutability

Try the free JavaScript compiler

String values cannot be changed in place. Operations produce values; assignment changes a binding rather than editing the source string.

Formal Syntax & Structure

javascript syntaxjavascript
const result = text.replace(search, replacement);

Working Example

Example Snippetjavascript
let s="red"; const r=s.replace("r","b"); console.log(s,r);
JavaScript Reference