JAVASCRIPT
REMINDER




Last update:   26-01-2022

Backsticks

With backsticks we can embed any expression into the string.
 
/**
 * Backsticks quotes
 * 
 * We can embed any expression into the string.
 * We can span multiple lines.
 * 
 * All special characters start with a backslash character.
 */

let str = 'World';
console.log(`Hello ${str}`); // Hello World

let guestList = `Guests:
    * John
    * Pete
    * Mary
`;
console.log(guestList);
/*
    * John
    * Pete
    * Mary
*/

console.log('Object\'s properties'); // Object's properties
console.log('One backslash \\'); // One backslash \

Substring

Modern Javascript has methods like include, startsWith.
 
/**
 * Substring methods
 */

// Includes
console.log("Widget with id".includes('id')); // true
console.log('Widget'.includes('id', 2)); // false

// Start with
console.log('Widget'.startsWith('Wid')); // true
console.log('Widget'.endsWith('get')); // true

// Substring
console.log('Widget'.slice(0, 3)); // Wid

// Position
console.log('Widget'.charAt('0')); // W
console.log('Widget'.indexOf('id')); // 1

Questions     github Types
Arrays
        A B C D E F
🔔
1/3