Constant declaration of surname - can’t change this let forename = 'Walter' // First declaration of forename function sayMyName () { forename = 'Flynn' // `let` can be overridden let nickname = 'Walt Jr.' // Block-scoped declaration of nickname let fullName = forename + ' \'' + nickname + '\' ' + surname console.log(fullName) } console.log(nickname) // Uncaught ReferenceError: nickname is not defined surname = 'White!' // SyntaxError: "surname" is read-only
the one who knocks` quote.startsWith('I') // true quote.startsWith('Me') // false quote.endsWith('knocks') // true quote.endsWith('rings') // false quote.includes('the') // true quote.repeat(2) // I am the one who knocksI am the one who knocks
'Jesse' ] let name = characters.find(function (name) { return name !== 'Jesse' }) // Returns first element that matches the query // e.g. 'Walt' Array.find()
'Walt', 'Jesse' ] let nameIndex = characters.findIndex(function (name) { return name !== 'Hank' }) // Returns first element index that is true // or -1 for false // Better than (indexOf(name) !== -1)