Skip to content

Instantly share code, notes, and snippets.

@KinoAR
Last active November 1, 2016 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KinoAR/c8cbd22c093bcd35b19a803b49fd947e to your computer and use it in GitHub Desktop.
Save KinoAR/c8cbd22c093bcd35b19a803b49fd947e to your computer and use it in GitHub Desktop.
//=============================================================================
// Strings
//=============================================================================
//String Examples
//String Literals
//Double quotes
var string1 = "Hello World";
//Single quotes
var string2 = 'Hello World';
//Template Literals
var templateLiteralString = `Hello World`;
//Both String Literals and Template Literals can use string methods.
//Repeat
console.log(string1.repeat(2)); //Hello WorldHello World
//Includes
console.log(string1.includes("Hello")); //True
console.log(string1.includes("World")); //True
//IndexOf
console.log(string1.indexOf('H')); //0
console.log(string1.indexOf('W')); //6
//StartsWith
console.log(string1.startsWith("Hello")); //True
console.log(string1.startsWith("World")); //False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment