SyntaxStudy
Sign Up
JavaScript Beginner 1 min read

Strings

JavaScript Strings

Template Literals

Use backticks for embedded expressions: `Hello, ${name}!`

Methods

MethodDescription
.lengthCharacter count
.toUpperCase()All caps
.includes(s)Contains?
.slice(s,e)Substring
.replace(a,b)Replace
.trim()Remove whitespace
.split(s)To array
Example
const name='Alice';
console.log(`Hello, ${name}!`);
console.log(name.toUpperCase()); // ALICE
console.log(name.length);        // 5
console.log('a,b,c'.split(',')); // ['a','b','c']